Added the warning code
WARN_PARSE_REDUNDANT 322 similar to the g++ -Wredundant-decls flag. This recovers the warnings that now are not been reported by the original code WARN_PARSE_REDEFINED 302 Redundant example: int foo(int); int foo(int); Redefined example: int foo(int); double foo(int); git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5634 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
eaa0062cd2
commit
74d6f1eb43
6 changed files with 63 additions and 25 deletions
|
|
@ -376,21 +376,30 @@ static void add_symbols(Node *n) {
|
|||
String *e = NewString("");
|
||||
String *en = NewString("");
|
||||
String *ec = NewString("");
|
||||
Printf(en,"Identifier '%s' redeclared (ignored)", symname);
|
||||
int redefined = need_redefined_warn(n,c,inclass);
|
||||
if (redefined) {
|
||||
Printf(en,"Identifier '%s' redefined (ignored)",symname);
|
||||
Printf(ec,"previous definition of '%s'",symname);
|
||||
} else {
|
||||
Printf(en,"Redundant redeclaration of '%s'",symname);
|
||||
Printf(ec,"previous declaration of '%s'",symname);
|
||||
}
|
||||
if (Cmp(symname,Getattr(n,"name"))) {
|
||||
Printf(en," (Renamed from '%s')", SwigType_namestr(Getattr(n,"name")));
|
||||
}
|
||||
Printf(en,",");
|
||||
Printf(ec," previous declaration of '%s'", symname);
|
||||
if (Cmp(symname,Getattr(c,"name"))) {
|
||||
Printf(ec," (Renamed from '%s')", SwigType_namestr(Getattr(c,"name")));
|
||||
}
|
||||
Printf(ec,".");
|
||||
if (need_redefined_warn(n, c, inclass)) {
|
||||
if (redefined) {
|
||||
Swig_warning(WARN_PARSE_REDEFINED,Getfile(n),Getline(n),"%s\n",en);
|
||||
Swig_warning(WARN_PARSE_REDEFINED,Getfile(c),Getline(c),"%s\n",ec);
|
||||
} else if (!is_friend(n) && !is_friend(c)) {
|
||||
Swig_warning(WARN_PARSE_REDUNDANT,Getfile(n),Getline(n),"%s\n",en);
|
||||
Swig_warning(WARN_PARSE_REDUNDANT,Getfile(c),Getline(c),"%s\n",ec);
|
||||
}
|
||||
Printf(e,"%s\n%s:%d:%s\n", en, Getfile(c), Getline(c), ec);
|
||||
Printf(e,"%s\n%s:%d:%s\n",en,Getfile(c),Getline(c),ec);
|
||||
Setattr(n,"error",e);
|
||||
Delete(en);
|
||||
Delete(ec);
|
||||
|
|
@ -535,8 +544,8 @@ static void merge_extensions(Node *cls, Node *am) {
|
|||
String *e = NewString("");
|
||||
String *en = NewString("");
|
||||
String *ec = NewString("");
|
||||
Printf(ec,"Identifier '%s' redeclared (ignored),\n", symname);
|
||||
Printf(en," %%extend definition of '%s'.", symname);
|
||||
Printf(ec,"Identifier '%s' redefined by %extend (ignored),\n", symname);
|
||||
Printf(en,"%%extend definition of '%s'.", symname);
|
||||
Swig_warning(WARN_PARSE_REDEFINED,Getfile(csym), Getline(csym), "%s\n", ec);
|
||||
Swig_warning(WARN_PARSE_REDEFINED,Getfile(n), Getline(n), "%s\n", en);
|
||||
Printf(e,"%s\n%s:%d:%s\n", ec, Getfile(n), Getline(n), en);
|
||||
|
|
@ -1312,7 +1321,7 @@ includetype : INCLUDE { $$.type = (char *) "include"; }
|
|||
inline_directive : INLINE HBLOCK {
|
||||
String *cpps;
|
||||
if (Namespaceprefix) {
|
||||
Swig_error(cparse_file, cparse_start_line, "Error. %%inline directive inside a namespace is disallowed.\n");
|
||||
Swig_error(cparse_file, cparse_start_line, "%%inline directive inside a namespace is disallowed.\n");
|
||||
|
||||
$$ = 0;
|
||||
} else {
|
||||
|
|
@ -1333,7 +1342,7 @@ inline_directive : INLINE HBLOCK {
|
|||
String *cpps;
|
||||
skip_balanced('{','}');
|
||||
if (Namespaceprefix) {
|
||||
Swig_error(cparse_file, cparse_start_line, "Error. %%inline directive inside a namespace is disallowed.\n");
|
||||
Swig_error(cparse_file, cparse_start_line, "%%inline directive inside a namespace is disallowed.\n");
|
||||
|
||||
$$ = 0;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -170,6 +170,7 @@ int are_equivalent_nodes(Node* a, Node* b, int a_inclass)
|
|||
|
||||
if (!a_inclass || (Cmp(a_storage,"friend") == 0)) {
|
||||
/* check declaration */
|
||||
|
||||
String *a_decl = (Getattr(a,"decl"));
|
||||
String *b_decl = (Getattr(b,"decl"));
|
||||
if (Cmp(a_decl, b_decl) == 0) {
|
||||
|
|
@ -216,8 +217,12 @@ int are_equivalent_nodes(Node* a, Node* b, int a_inclass)
|
|||
|
||||
int need_redefined_warn(Node* a, Node* b, int InClass)
|
||||
{
|
||||
String *a_storage = Getattr(a,"storage");
|
||||
String *b_storage = Getattr(b,"storage");
|
||||
String *a_symname = Getattr(a,"sym:name");
|
||||
String *b_symname = Getattr(b,"sym:name");
|
||||
/* always send a warning if a 'rename' is involved */
|
||||
if ((a_symname && Cmp(a_symname,Getattr(a,"name")))
|
||||
|| (b_symname && Cmp(b_symname,Getattr(b,"name"))))
|
||||
return 1;
|
||||
|
||||
return !are_equivalent_nodes(a, b, InClass);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@
|
|||
#define WARN_PARSE_TEMPLATE_AMBIG 318
|
||||
#define WARN_PARSE_NO_ACCESS 319
|
||||
#define WARN_PARSE_EXPLICIT_TEMPLATE 320
|
||||
#define WARN_PARSE_BUILTIN_NAME 321
|
||||
#define WARN_PARSE_REDUNDANT 322
|
||||
|
||||
#define WARN_IGNORE_OPERATOR_NEW 350 /* new */
|
||||
#define WARN_IGNORE_OPERATOR_DELETE 351 /* delete */
|
||||
|
|
|
|||
|
|
@ -232,10 +232,17 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
/* Initialize the SWIG core */
|
||||
Swig_init();
|
||||
|
||||
/* Suppress warning messages for private inheritance, preprocessor evaluation,
|
||||
might be abstract, and overloaded const */
|
||||
/* Suppress warning messages for private inheritance, preprocessor
|
||||
evaluation, might be abstract, overloaded const, and ...
|
||||
|
||||
Swig_warnfilter("202,309,403,512,321",1);
|
||||
WARN_PP_EVALUATION 202
|
||||
WARN_PARSE_PRIVATE_INHERIT 309
|
||||
WARN_TYPE_ABSTRACT 403
|
||||
WARN_LANG_OVERLOAD_CONST 512
|
||||
WARN_PARSE_BUILTIN_NAME 321
|
||||
WARN_PARSE_REDUNDANT 322
|
||||
*/
|
||||
Swig_warnfilter("202,309,403,512,321,322",1);
|
||||
|
||||
// Initialize the preprocessor
|
||||
Preprocessor_init();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue