- Normalize the 'Swig_error' calls and formats, before some
of the strings start like "Error. XXX", others like "XXX". The format is now defined in 'error.c:Swig_error_msg_format()'. - Normalize the multiline error/warning messages to correctly use -Fformat definition. - Centralize the error/warning format definitions in 'error.c:Swig_error_msg_format()'. - Fix a minor error in cpp.c, that after finding an error, still was emitting a redefined macro, producing duplicated error/warning messages in parser.y. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5635 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
aa8b13473e
commit
48d11474ee
8 changed files with 65 additions and 41 deletions
|
|
@ -517,8 +517,12 @@ Swig_cparse_template_locate(String *name, Parm *tparms) {
|
||||||
n = Swig_symbol_clookup_local(s,0);
|
n = Swig_symbol_clookup_local(s,0);
|
||||||
if (Len(mpartials) > 1) {
|
if (Len(mpartials) > 1) {
|
||||||
if (n) {
|
if (n) {
|
||||||
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG,cparse_file,cparse_line,"Instantiation of template %s is ambiguous. Using %s at %s:%d\n",
|
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG,cparse_file,cparse_line,
|
||||||
SwigType_namestr(tname), SwigType_namestr(Getattr(n,"name")), Getfile(n),Getline(n));
|
"Instantiation of template '%s' is ambiguous,\n",
|
||||||
|
SwigType_namestr(tname));
|
||||||
|
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG,Getfile(n),Getline(n),
|
||||||
|
" instantiation '%s' is used.\n",
|
||||||
|
SwigType_namestr(Getattr(n,"name")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -289,7 +289,7 @@ class Allocate : public Dispatcher {
|
||||||
if (e && is_public(e) && !Getattr(e,"feature:ignore") && (Cmp(symname, Getattr(e,"sym:name")) == 0)) {
|
if (e && is_public(e) && !Getattr(e,"feature:ignore") && (Cmp(symname, Getattr(e,"sym:name")) == 0)) {
|
||||||
Swig_warning(WARN_LANG_DEREF_SHADOW,Getfile(e),Getline(e),"Declaration of '%s' shadows declaration accessible via operator->(),\n",
|
Swig_warning(WARN_LANG_DEREF_SHADOW,Getfile(e),Getline(e),"Declaration of '%s' shadows declaration accessible via operator->(),\n",
|
||||||
name);
|
name);
|
||||||
Swig_warning(WARN_LANG_DEREF_SHADOW,Getfile(c),Getline(c)," '%s' first declared here.\n", name);
|
Swig_warning(WARN_LANG_DEREF_SHADOW,Getfile(c),Getline(c),"previous declaration of '%s'.\n", name);
|
||||||
} else {
|
} else {
|
||||||
/* Make sure node with same name doesn't already exist */
|
/* Make sure node with same name doesn't already exist */
|
||||||
int k;
|
int k;
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ int emit_num_required(ParmList *parms) {
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p,"tmap:in:next");
|
||||||
} else {
|
} else {
|
||||||
if (!Getattr(p,"value") && (!Getattr(p,"tmap:default"))) {
|
if (!Getattr(p,"value") && (!Getattr(p,"tmap:default"))) {
|
||||||
Swig_error(Getfile(p),Getline(p),"Error. Non-optional argument '%s' follows an optional argument.\n",Getattr(p,"name"));
|
Swig_error(Getfile(p),Getline(p),"Non-optional argument '%s' follows an optional argument.\n",Getattr(p,"name"));
|
||||||
}
|
}
|
||||||
if (Getattr(p,"tmap:in")) {
|
if (Getattr(p,"tmap:in")) {
|
||||||
p = Getattr(p,"tmap:in:next");
|
p = Getattr(p,"tmap:in:next");
|
||||||
|
|
|
||||||
|
|
@ -2097,7 +2097,7 @@ int
|
||||||
Language::addSymbol(String *s, Node *n) {
|
Language::addSymbol(String *s, Node *n) {
|
||||||
Node *c = Getattr(symbols,s);
|
Node *c = Getattr(symbols,s);
|
||||||
if (c && (c != n)) {
|
if (c && (c != n)) {
|
||||||
Swig_error(input_file, line_number, "Error. '%s' is multiply defined in the generated module.\n", s);
|
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated module.\n", s);
|
||||||
Swig_error(Getfile(c),Getline(c), "Previous declaration of '%s'\n", s);
|
Swig_error(Getfile(c),Getline(c), "Previous declaration of '%s'\n", s);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -405,8 +405,12 @@ public:
|
||||||
SwigType_typedef_class(fname);
|
SwigType_typedef_class(fname);
|
||||||
scopename = Copy(fname);
|
scopename = Copy(fname);
|
||||||
} else {
|
} else {
|
||||||
Swig_warning(WARN_TYPE_REDEFINED,Getfile(n),Getline(n),"Template '%s' was already wrapped as '%s' at %s:%d.\n",
|
Swig_warning(WARN_TYPE_REDEFINED,Getfile(n),Getline(n),
|
||||||
SwigType_namestr(name), SwigType_namestr(Getattr(cn,"name")), Getfile(cn), Getline(cn));
|
"Template '%s' was already wrapped,\n",
|
||||||
|
SwigType_namestr(name));
|
||||||
|
Swig_warning(WARN_TYPE_REDEFINED,Getfile(cn), Getline(cn),
|
||||||
|
"previous wrap of '%s'.\n",
|
||||||
|
SwigType_namestr(Getattr(cn,"name")));
|
||||||
scopename = 0;
|
scopename = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,6 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
|
||||||
/* Go create the macro */
|
/* Go create the macro */
|
||||||
macro = NewHash();
|
macro = NewHash();
|
||||||
Setattr(macro,"name", macroname);
|
Setattr(macro,"name", macroname);
|
||||||
Delete(macroname);
|
|
||||||
if (arglist) {
|
if (arglist) {
|
||||||
Setattr(macro,"args",arglist);
|
Setattr(macro,"args",arglist);
|
||||||
Delete(arglist);
|
Delete(arglist);
|
||||||
|
|
@ -362,17 +361,23 @@ Hash *Preprocessor_define(const String_or_char *_str, int swigmacro)
|
||||||
}
|
}
|
||||||
symbols = Getattr(cpp,"symbols");
|
symbols = Getattr(cpp,"symbols");
|
||||||
if ((m1 = Getattr(symbols,macroname))) {
|
if ((m1 = Getattr(symbols,macroname))) {
|
||||||
if (Cmp(Getattr(m1,"value"),macrovalue))
|
if (Cmp(Getattr(m1,"value"),macrovalue)) {
|
||||||
Swig_error(Getfile(str),Getline(str),"Macro '%s' redefined. Previous definition in \'%s\', Line %d\n", macroname, Getfile(m1), Getline(m1));
|
Swig_error(Getfile(str),Getline(str),"Macro '%s' redefined,\n",macroname);
|
||||||
|
Swig_error(Getfile(m1),Getline(m1),"previous definition of '%s'.\n",macroname);
|
||||||
|
goto macro_error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Setattr(symbols,macroname,macro);
|
Setattr(symbols,macroname,macro);
|
||||||
|
|
||||||
Delete(str);
|
Delete(str);
|
||||||
Delete(argstr);
|
Delete(argstr);
|
||||||
|
Delete(macroname);
|
||||||
return macro;
|
return macro;
|
||||||
|
|
||||||
macro_error:
|
macro_error:
|
||||||
Delete(str);
|
Delete(str);
|
||||||
Delete(argstr);
|
Delete(argstr);
|
||||||
|
Delete(macroname);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,12 @@ static String *filter = 0; /* Warning filter */
|
||||||
static int warnall = 0;
|
static int warnall = 0;
|
||||||
static int nwarning = 0;
|
static int nwarning = 0;
|
||||||
|
|
||||||
|
static int init_fmt = 0;
|
||||||
|
static char wrn_wnum_fmt[64];
|
||||||
|
static char wrn_nnum_fmt[64];
|
||||||
|
static char err_line_fmt[64];
|
||||||
|
static char err_eof_fmt[64];
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Swig_warning()
|
* Swig_warning()
|
||||||
*
|
*
|
||||||
|
|
@ -58,6 +64,7 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt
|
||||||
int wrn = 1;
|
int wrn = 1;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
if (silence) return;
|
if (silence) return;
|
||||||
|
if (!init_fmt) Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
|
||||||
|
|
||||||
va_start(ap,fmt);
|
va_start(ap,fmt);
|
||||||
|
|
||||||
|
|
@ -90,25 +97,9 @@ Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt
|
||||||
}
|
}
|
||||||
if (warnall || wrn) {
|
if (warnall || wrn) {
|
||||||
if (wnum) {
|
if (wnum) {
|
||||||
switch (msg_format) {
|
Printf(stderr, wrn_wnum_fmt, filename, line, wnum);
|
||||||
case EMF_MICROSOFT:
|
|
||||||
Printf(stderr,"%s(%d): Warning(%d): ", filename, line, wnum);
|
|
||||||
break;
|
|
||||||
case EMF_STANDARD:
|
|
||||||
default:
|
|
||||||
Printf(stderr,"%s:%d: Warning(%d): ", filename, line, wnum);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
switch (msg_format) {
|
Printf(stderr, wrn_nnum_fmt, filename, line);
|
||||||
case EMF_MICROSOFT:
|
|
||||||
Printf(stderr,"%s(%d): Warning: ", filename, line);
|
|
||||||
break;
|
|
||||||
case EMF_STANDARD:
|
|
||||||
default:
|
|
||||||
Printf(stderr,"%s:%d: Warning: ", filename, line);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Printf(stderr,"%s",msg);
|
Printf(stderr,"%s",msg);
|
||||||
nwarning++;
|
nwarning++;
|
||||||
|
|
@ -130,20 +121,13 @@ Swig_error(const String_or_char *filename, int line, const char *fmt, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
if (silence) return;
|
if (silence) return;
|
||||||
|
if (!init_fmt) Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
|
||||||
|
|
||||||
va_start(ap,fmt);
|
va_start(ap,fmt);
|
||||||
if (line > 0) {
|
if (line > 0) {
|
||||||
switch (msg_format) {
|
Printf(stderr, err_line_fmt, filename, line);
|
||||||
case EMF_MICROSOFT:
|
|
||||||
Printf(stderr,"%s(%d): ", filename, line);
|
|
||||||
break;
|
|
||||||
case EMF_STANDARD:
|
|
||||||
default:
|
|
||||||
Printf(stderr,"%s:%d: ", filename, line);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Printf(stderr,"%s:EOF: ", filename);
|
Printf(stderr, err_eof_fmt, filename);
|
||||||
}
|
}
|
||||||
vPrintf(stderr,fmt,ap);
|
vPrintf(stderr,fmt,ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
@ -235,5 +219,28 @@ Swig_warn_count(void) {
|
||||||
|
|
||||||
void
|
void
|
||||||
Swig_error_msg_format(ErrorMessageFormat format) {
|
Swig_error_msg_format(ErrorMessageFormat format) {
|
||||||
|
const char* error = "Error";
|
||||||
|
const char* warning = "Warning";
|
||||||
|
|
||||||
|
const char* fmt_eof = "%s:EOF";
|
||||||
|
|
||||||
|
/* here 'format' could be directly a string instead of an enum, but
|
||||||
|
by now a switch is used to translated into one. */
|
||||||
|
const char* fmt_line = 0;
|
||||||
|
switch (format) {
|
||||||
|
case EMF_MICROSOFT:
|
||||||
|
fmt_line = "%s(%d)";
|
||||||
|
break;
|
||||||
|
case EMF_STANDARD:
|
||||||
|
default:
|
||||||
|
fmt_line = "%s:%d";
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(wrn_wnum_fmt, "%s: %s(%%d): ", fmt_line, warning);
|
||||||
|
sprintf(wrn_nnum_fmt, "%s: %s: ", fmt_line, warning);
|
||||||
|
sprintf(err_line_fmt, "%s: %s: ", fmt_line, error);
|
||||||
|
sprintf(err_eof_fmt, "%s: %s: ", fmt_eof, error);
|
||||||
|
|
||||||
msg_format = format;
|
msg_format = format;
|
||||||
|
init_fmt = 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -383,8 +383,12 @@ Swig_symbol_cadd(String_or_char *name, Node *n) {
|
||||||
Setattr(ccurrent,name,n);
|
Setattr(ccurrent,name,n);
|
||||||
append = cn;
|
append = cn;
|
||||||
} else if (cn && (Strcmp(nodeType(cn),"templateparm") == 0)) {
|
} else if (cn && (Strcmp(nodeType(cn),"templateparm") == 0)) {
|
||||||
Swig_error(Getfile(n),Getline(n),"Error. Declaration of '%s' shadows template parameter at %s:%d\n",
|
Swig_error(Getfile(n),Getline(n),
|
||||||
name,Getfile(cn),Getline(cn));
|
"Declaration of '%s' shadows template parameter,\n",
|
||||||
|
name);
|
||||||
|
Swig_error(Getfile(cn),Getline(cn),
|
||||||
|
"previous template parameter declaration '%s'.\n",
|
||||||
|
name);
|
||||||
return;
|
return;
|
||||||
} else if (cn) {
|
} else if (cn) {
|
||||||
append = n;
|
append = n;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue