From e1b5d43cd8e3cf899fa771333d337dff59d00a4f Mon Sep 17 00:00:00 2001 From: Matevz Jekovec Date: Sat, 11 Jul 2009 20:13:36 +0000 Subject: [PATCH] Added C++0x support for 'extern' explicit template instantiation without the translation unit. Added test cases. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@11385 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 3 ++- Examples/test-suite/cpp0x_constexpr.i | 3 ++- Examples/test-suite/cpp0x_explicit_conversion_operators.i | 2 +- Examples/test-suite/cpp0x_raw_string_literals.i | 3 +-- Examples/test-suite/cpp0x_static_assert.i | 2 +- Examples/test-suite/cpp0x_template_double_brackets.i | 2 +- Source/CParse/parser.y | 8 ++++++-- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index c0fdd0d96..bd5f7b983 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -403,7 +403,8 @@ CPP0X_TEST_CASES = \ cpp0x_template_double_brackets \ cpp0x_explicit_conversion_operators \ cpp0x_raw_string_literals \ - cpp0x_static_assert + cpp0x_static_assert \ + cpp0x_template_explicit # cpp0x_constexpr # not supported by any compilers yet # Broken C++0x test cases. diff --git a/Examples/test-suite/cpp0x_constexpr.i b/Examples/test-suite/cpp0x_constexpr.i index 4345ec0af..6cae41825 100644 --- a/Examples/test-suite/cpp0x_constexpr.i +++ b/Examples/test-suite/cpp0x_constexpr.i @@ -1,10 +1,11 @@ /* This interface tests whether Swig supports the new "constexpr" keyword introduced by C++0x. */ -%module foo +%module cpp0x_constexpr %inline %{ class TestClass { +public: constexpr int func() { return 10; } }; %} diff --git a/Examples/test-suite/cpp0x_explicit_conversion_operators.i b/Examples/test-suite/cpp0x_explicit_conversion_operators.i index ae97ec185..6532efb23 100644 --- a/Examples/test-suite/cpp0x_explicit_conversion_operators.i +++ b/Examples/test-suite/cpp0x_explicit_conversion_operators.i @@ -1,7 +1,7 @@ /* This interface checks whether Swig correctly compiles the new explicit conversion operators feature introduced in C++0x. */ -%module foo +%module cpp0x_explicit_conversion_operators %inline %{ diff --git a/Examples/test-suite/cpp0x_raw_string_literals.i b/Examples/test-suite/cpp0x_raw_string_literals.i index 7e0814768..4da565264 100644 --- a/Examples/test-suite/cpp0x_raw_string_literals.i +++ b/Examples/test-suite/cpp0x_raw_string_literals.i @@ -7,8 +7,7 @@ This module also tests whether Swig correctly parses custom string delimiters. */ - -%module raw_string_literals +%module cpp0x_raw_string_literals %inline %{ #include diff --git a/Examples/test-suite/cpp0x_static_assert.i b/Examples/test-suite/cpp0x_static_assert.i index 112168f5e..28c244c87 100644 --- a/Examples/test-suite/cpp0x_static_assert.i +++ b/Examples/test-suite/cpp0x_static_assert.i @@ -1,7 +1,7 @@ /* This test case checks whether swig correctly parses and ignores the keywords "static_assert()" inside the class or struct. */ -%module static_assert +%module cpp0x_static_assert %inline %{ template diff --git a/Examples/test-suite/cpp0x_template_double_brackets.i b/Examples/test-suite/cpp0x_template_double_brackets.i index 31c9c7248..74d2fc768 100644 --- a/Examples/test-suite/cpp0x_template_double_brackets.i +++ b/Examples/test-suite/cpp0x_template_double_brackets.i @@ -2,7 +2,7 @@ in the template syntax without having a space inbetween. This feature was introduced in new C++0x standard. */ -%module foo +%module cpp0x_template_double_brackets %inline %{ #include std::map> m; diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 47dc091f4..67cf2dd53 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3850,10 +3850,14 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para Namespaceprefix = Swig_symbol_qualifiedscopename(0); if (error) $$ = 0; } - | TEMPLATE cpptype idcolon { + | TEMPLATE cpptype idcolon { /* Explicit template instantiation */ Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n"); $$ = 0; - } + } + | EXTERN TEMPLATE cpptype idcolon { /* Explicit template instantiation without the translation unit */ + Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n"); + $$ = 0; + } ; cpp_temp_possible: c_decl {