diff --git a/CHANGES.current b/CHANGES.current index c3cb5f951..bb1377c0c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.1.0 (in progress) =========================== +2022-02-20: wsfulton + Fix %warnfilter warning suppress for warning 315 SWIGWARN_PARSE_USING_UNDEF. + 2022-02-17: olly [PHP] https://sourceforge.net/p/swig/bugs/1211/ Fix to call cleanup code in exception situations and not to invoke diff --git a/Examples/test-suite/using2.i b/Examples/test-suite/using2.i index 1f3dc46f5..1c471c1e5 100644 --- a/Examples/test-suite/using2.i +++ b/Examples/test-suite/using2.i @@ -1,6 +1,6 @@ %module using2 -%warnfilter(SWIGWARN_PARSE_USING_UNDEF); +%warnfilter(SWIGWARN_PARSE_USING_UNDEF) ::baz; using ::baz; diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 5a0ec8e65..6317c1776 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1863,7 +1863,7 @@ extend_directive : EXTEND options classkeyopt idcolon LBRACE { } else { /* Previous typedef class definition. Use its symbol table. Deprecated, just the real name should be used. - Note that %extend before the class typedef never worked, only %extend after the class typdef. */ + Note that %extend before the class typedef never worked, only %extend after the class typedef. */ prev_symtab = Swig_symbol_setscope(Getattr(cls, "symtab")); current_class = cls; SWIG_WARN_NODE_BEGIN(cls); @@ -4481,12 +4481,11 @@ templateparameterstail : COMMA templateparameter templateparameterstail { /* Namespace support */ cpp_using_decl : USING idcolon SEMI { - String *uname = Swig_symbol_type_qualify($2,0); + String *uname = Swig_symbol_type_qualify($2,0); String *name = Swig_scopename_last($2); - $$ = new_node("using"); + $$ = new_node("using"); Setattr($$,"uname",uname); Setattr($$,"name", name); - Swig_symbol_add_using(name, uname, $$); Delete(uname); Delete(name); add_symbols($$); diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx index b0a699fb6..01b577e20 100644 --- a/Source/Modules/javascript.cxx +++ b/Source/Modules/javascript.cxx @@ -1143,7 +1143,7 @@ int JSEmitter::emitConstant(Node *n) { String *rawval = Getattr(n, "rawval"); String *value = rawval ? rawval : Getattr(n, "value"); - // HACK: forcing usage of cppvalue for v8 (which turned out to fix typdef_struct.i, et. al) + // HACK: forcing usage of cppvalue for v8 (which turned out to fix typedef_struct.i, et. al) if (State::IsSet(state.globals(FORCE_CPP)) && Getattr(n, "cppvalue") != NULL) { value = Getattr(n, "cppvalue"); } diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 9f7b2cbca..76691269e 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -221,7 +221,6 @@ extern "C" { extern void Swig_symbol_print_tables_summary(void); extern void Swig_symbol_print_symbols(void); extern void Swig_symbol_print_csymbols(void); - extern void Swig_symbol_add_using(String *name, String *uname, Node *n); extern void Swig_symbol_init(void); extern void Swig_symbol_setscopename(const_String_or_char_ptr name); extern String *Swig_symbol_getscopename(void); diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index 66c73ae02..d3bc720ff 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -12,7 +12,7 @@ * ----------------------------------------------------------------------------- */ #include "swig.h" -#include "swigwarn.h" +#include "cparse.h" #include /* #define SWIG_DEBUG*/ @@ -382,29 +382,6 @@ String *Swig_symbol_qualified_language_scopename(Symtab *n) { return result; } -/* ----------------------------------------------------------------------------- - * Swig_symbol_add_using() - * - * Adds a node to the C symbol table for a using declaration. - * Used for using-declarations within classes/structs. - * ----------------------------------------------------------------------------- */ - -void Swig_symbol_add_using(String *name, String *uname, Node *n) { - Hash *h; - h = Swig_symbol_clookup(uname, 0); - if (h && (checkAttribute(h, "kind", "class") || checkAttribute(h, "kind", "struct"))) { - String *qcurrent = Swig_symbol_qualifiedscopename(0); - if (qcurrent) { - Append(qcurrent, "::"); - Append(qcurrent, name); - } else { - qcurrent = NewString(name); - } - Setattr(symtabs, qcurrent, n); - Delete(qcurrent); - } -} - /* ----------------------------------------------------------------------------- * Swig_symbol_newscope() * @@ -664,10 +641,11 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) { { Node *td = n; - while (td && Checkattr(td, "nodeType", "cdecl") && Checkattr(td, "storage", "typedef")) { + while (td && ((Equal(nodeType(td), "cdecl") && Checkattr(td, "storage", "typedef")) || (Equal(nodeType(td), "using") && !Getattr(n, "namespace")))) { SwigType *type; Node *td1; - type = Copy(Getattr(td, "type")); + int using_not_typedef = Equal(nodeType(td), "using"); + type = Copy(Getattr(td, using_not_typedef ? "uname" : "type")); SwigType_push(type, Getattr(td, "decl")); td1 = Swig_symbol_clookup(type, 0); @@ -688,9 +666,13 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) { ie, when Foo -> FooBar -> Foo, jump one scope up when possible. */ - if (td1 && Checkattr(td1, "storage", "typedef")) { - String *st = Getattr(td1, "type"); + if (td1) { + String *st = 0; String *sn = Getattr(td, "name"); + if (Equal(nodeType(td1), "cdecl") && Checkattr(td1, "storage", "typedef")) + st = Getattr(td1, "type"); + else if (Equal(nodeType(td1), "using") && !Getattr(td1, "namespace")) + st = Getattr(td1, "uname"); if (st && sn && Equal(st, sn)) { Symtab *sc = Getattr(current_symtab, "parentNode"); if (sc) @@ -1097,19 +1079,7 @@ static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symt Delete(qalloc); return st; } - if (checkAttribute(st, "nodeType", "using")) { - String *uname = Getattr(st, "uname"); - if (uname) { - st = Getattr(symtabs, uname); - if (st) { - n = symbol_lookup(name, st, checkfunc); - } else { - fprintf(stderr, "Error: Found corrupt 'using' node\n"); - } - } - } else if (Getattr(st, "csymtab")) { - n = symbol_lookup(name, st, checkfunc); - } + n = symbol_lookup(name, st, checkfunc); } if (qalloc) Delete(qalloc); @@ -1212,7 +1182,9 @@ Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) { Symtab *un = Getattr(s, "sym:symtab"); Node *ss = (!Equal(name, uname) || (un != n)) ? Swig_symbol_clookup(uname, un) : 0; /* avoid infinity loop */ if (!ss) { + SWIG_WARN_NODE_BEGIN(s); Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname"))); + SWIG_WARN_NODE_END(s); } s = ss; } @@ -1284,7 +1256,9 @@ Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (* Node *ss; ss = Swig_symbol_clookup(Getattr(s, "uname"), Getattr(s, "sym:symtab")); if (!ss && !checkfunc) { + SWIG_WARN_NODE_BEGIN(s); Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname"))); + SWIG_WARN_NODE_END(s); } s = ss; } @@ -1335,7 +1309,9 @@ Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) { while (s && Checkattr(s, "nodeType", "using")) { Node *ss = Swig_symbol_clookup_local(Getattr(s, "uname"), Getattr(s, "sym:symtab")); if (!ss) { + SWIG_WARN_NODE_BEGIN(s); Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname"))); + SWIG_WARN_NODE_END(s); } s = ss; } @@ -1383,7 +1359,9 @@ Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n, while (s && Checkattr(s, "nodeType", "using")) { Node *ss = Swig_symbol_clookup_local_check(Getattr(s, "uname"), Getattr(s, "sym:symtab"), checkfunc); if (!ss && !checkfunc) { + SWIG_WARN_NODE_BEGIN(s); Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname"))); + SWIG_WARN_NODE_END(s); } s = ss; }