Rework std::initializer_list handling to warn about usage in any method, not just constructors. A typemap is used to issue the warning and can be overridden with user defined behaviour.
This commit is contained in:
parent
c8ff23de0c
commit
d613ef42f2
10 changed files with 259 additions and 134 deletions
|
|
@ -4635,27 +4635,21 @@ cpp_member : c_declaration { $$ = $1; }
|
|||
|
||||
cpp_constructor_decl : storage_class type LPAREN parms RPAREN ctor_end {
|
||||
if (Classprefix) {
|
||||
if ($4 && 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");
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,6 +174,7 @@
|
|||
#define WARN_TYPEMAP_DIRECTOROUT_PTR 473
|
||||
#define WARN_TYPEMAP_OUT_OPTIMAL_IGNORED 474
|
||||
#define WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE 475
|
||||
#define WARN_TYPEMAP_INITIALIZER_LIST 476
|
||||
|
||||
/* -- Fragments -- */
|
||||
#define WARN_FRAGMENT_NOT_FOUND 490
|
||||
|
|
@ -201,7 +202,6 @@
|
|||
#define WARN_LANG_TEMPLATE_METHOD_IGNORE 519
|
||||
#define WARN_LANG_SMARTPTR_MISSING 520
|
||||
#define WARN_LANG_ILLEGAL_DESTRUCTOR 521
|
||||
#define WARN_LANG_INITIALIZER_LIST 522
|
||||
|
||||
/* -- Reserved (600-799) -- */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue