diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 268296f3c..992406535 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -415,7 +415,8 @@ CPP0X_TEST_CASES = \ cpp0x_decltype \ cpp0x_result_of \ cpp0x_default_delete \ - cpp0x_sizeof_object + cpp0x_sizeof_object \ + cpp0x_initializer_list # cpp0x_template_typedefs # not supported by any compiler yet # cpp0x_hash_types # not fully implemented yet # cpp0x_constructors # not supported by any compiler yet diff --git a/Examples/test-suite/cpp0x_initializer_list.i b/Examples/test-suite/cpp0x_initializer_list.i new file mode 100644 index 000000000..76bc741f5 --- /dev/null +++ b/Examples/test-suite/cpp0x_initializer_list.i @@ -0,0 +1,13 @@ +/* This testcase checks whether Swig correctly uses the new initializer_list + introduced in C++0x. */ +%module cpp0x_initializer_list + +%inline %{ +#include + +class A { +public: + A( std::initializer_list ) {} +}; +%} + diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 25731ee35..e12455197 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -4265,21 +4265,27 @@ cpp_member : c_declaration { $$ = $1; } cpp_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end { if (Classprefix) { - SwigType *decl = NewStringEmpty(); - $$ = new_node("constructor"); - Setattr($$,"storage",$1); - Setattr($$,"name",$2); - Setattr($$,"parms",$4); - SwigType_add_function(decl,$4); - Setattr($$,"decl",decl); - Setattr($$,"throws",$6.throws); - Setattr($$,"throw",$6.throwf); - if (Len(scanner_ccode)) { - String *code = Copy(scanner_ccode); - Setattr($$,"code",code); - Delete(code); - } - SetFlag($$,"feature:new"); + if (Getattr($4,"type") && strstr(Char(Getattr($4,"type")), "initializer_list<")) { + /* Ignore constructors containing initializer_list<> introduced in C++0x */ + Swig_warning(WARN_LANG_INITIALIZER_LIST, cparse_file, cparse_line, "Constructor with std::initializer_list<> argument ignored.\n"); + $$ = 0; + } else { + SwigType *decl = NewStringEmpty(); + $$ = new_node("constructor"); + Setattr($$,"storage",$1); + Setattr($$,"name",$2); + Setattr($$,"parms",$4); + SwigType_add_function(decl,$4); + Setattr($$,"decl",decl); + Setattr($$,"throws",$6.throws); + Setattr($$,"throw",$6.throwf); + if (Len(scanner_ccode)) { + String *code = Copy(scanner_ccode); + Setattr($$,"code",code); + Delete(code); + } + SetFlag($$,"feature:new"); + } } else { $$ = 0; } diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index e25e4408b..292aa0ba6 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -189,6 +189,7 @@ #define WARN_LANG_DIRECTOR_ABSTRACT 517 #define WARN_LANG_PORTABILITY_FILENAME 518 #define WARN_LANG_TEMPLATE_METHOD_IGNORE 519 +#define WARN_LANG_INITIALIZER_LIST 520 /* -- Reserved (600-799) -- */