Fix seg fault for global declarations declared erroneously without a name
This commit is contained in:
parent
4f235027f4
commit
b851e45e0a
3 changed files with 29 additions and 16 deletions
6
Examples/test-suite/errors/cpp_bad_global_memberptr.i
Normal file
6
Examples/test-suite/errors/cpp_bad_global_memberptr.i
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
%module xxx
|
||||||
|
|
||||||
|
struct Funcs {};
|
||||||
|
|
||||||
|
short (Funcs::* *)(bool) = 0;
|
||||||
|
short (Funcs::* const*)(bool) = 0;
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
cpp_bad_global_memberptr.i:5: Error: Missing symbol name for global declaration
|
||||||
|
cpp_bad_global_memberptr.i:6: Error: Missing symbol name for global declaration
|
||||||
|
|
@ -3040,29 +3040,34 @@ c_decl : storage_class type declarator initializer c_decl_tail {
|
||||||
Setattr($$,"bitfield", $4.bitfield);
|
Setattr($$,"bitfield", $4.bitfield);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Look for "::" declarations (ignored) */
|
if ($3.id) {
|
||||||
if (Strstr($3.id,"::")) {
|
/* Look for "::" declarations (ignored) */
|
||||||
/* This is a special case. If the scope name of the declaration exactly
|
if (Strstr($3.id, "::")) {
|
||||||
matches that of the declaration, then we will allow it. Otherwise, delete. */
|
/* This is a special case. If the scope name of the declaration exactly
|
||||||
String *p = Swig_scopename_prefix($3.id);
|
matches that of the declaration, then we will allow it. Otherwise, delete. */
|
||||||
if (p) {
|
String *p = Swig_scopename_prefix($3.id);
|
||||||
if ((Namespaceprefix && Strcmp(p, Namespaceprefix) == 0) ||
|
if (p) {
|
||||||
(Classprefix && Strcmp(p, Classprefix) == 0)) {
|
if ((Namespaceprefix && Strcmp(p, Namespaceprefix) == 0) ||
|
||||||
String *lstr = Swig_scopename_last($3.id);
|
(Classprefix && Strcmp(p, Classprefix) == 0)) {
|
||||||
Setattr($$,"name",lstr);
|
String *lstr = Swig_scopename_last($3.id);
|
||||||
Delete(lstr);
|
Setattr($$, "name", lstr);
|
||||||
set_nextSibling($$,$5);
|
Delete(lstr);
|
||||||
|
set_nextSibling($$, $5);
|
||||||
|
} else {
|
||||||
|
Delete($$);
|
||||||
|
$$ = $5;
|
||||||
|
}
|
||||||
|
Delete(p);
|
||||||
} else {
|
} else {
|
||||||
Delete($$);
|
Delete($$);
|
||||||
$$ = $5;
|
$$ = $5;
|
||||||
}
|
}
|
||||||
Delete(p);
|
|
||||||
} else {
|
} else {
|
||||||
Delete($$);
|
set_nextSibling($$, $5);
|
||||||
$$ = $5;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
set_nextSibling($$,$5);
|
Swig_error(cparse_file, cparse_line, "Missing symbol name for global declaration\n");
|
||||||
|
$$ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Alternate function syntax introduced in C++11:
|
/* Alternate function syntax introduced in C++11:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue