summaryrefslogtreecommitdiff
path: root/Source/Preprocessor
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2010-08-29 23:32:49 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2010-08-29 23:32:49 +0000
commit31b5f36b741f2eaaa44c52d0e21cd6598e8cc73f (patch)
treee06a5b75252a2ef025b83dd091cd2a5dc0a46bc6 /Source/Preprocessor
parent5a6443ebcfaf0865b347d24704b3acb06b4f20d9 (diff)
downloadswig-31b5f36b741f2eaaa44c52d0e21cd6598e8cc73f.tar.gz
Fix line number and file name reporting for some macro preprocessor warnings.
The line number of the macro argument has been corrected and the line number of the start of the macro instead of one past the end is used. Some examples: file.h:11: Error: Illegal macro argument name '..' file.h:19: Error: Macro 'DUPLICATE' redefined, file.h:15: Error: previous definition of 'DUPLICATE'. file.h:25: Error: Variable-length macro argument must be last parameter file.h:32: Error: Illegal character in macro argument name file.i:37: Error: Macro 'SIT' expects 2 arguments Code used for testing: // file.h %define SIT(ax,b) abc( %enddef %define MISSING_DOT1(a, b, ..) xxx %enddef %define MISSING_DOT2(..) xxx %enddef %define DUPLICATE(a,b) abc %enddef %define DUPLICATE(b) xxx %enddef %define VARARGS_WRONG(a, x, ..., b) xxx %enddef %define BAD_ARGNAME( a, b{c ) xxx %enddef SIT(1) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12195 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Source/Preprocessor')
-rw-r--r--Source/Preprocessor/cpp.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index 32f3a3bd4..38a52dc3f 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -337,7 +337,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
Putc(c, argstr);
}
if (c != ')') {
- Swig_error(Getfile(str), Getline(str), "Missing \')\' in macro parameters\n");
+ Swig_error(Getfile(argstr), Getline(argstr), "Missing \')\' in macro parameters\n");
goto macro_error;
}
break;
@@ -372,10 +372,10 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
argname = NewStringEmpty();
while ((c = Getc(argstr)) != EOF) {
if (c == ',') {
- varargname = Macro_vararg_name(argname, str);
+ varargname = Macro_vararg_name(argname, argstr);
if (varargname) {
Delete(varargname);
- Swig_error(Getfile(str), Getline(str), "Variable-length macro argument must be last parameter\n");
+ Swig_error(Getfile(argstr), Getline(argstr), "Variable length macro argument must be last parameter\n");
} else {
Append(arglist, argname);
}
@@ -385,13 +385,13 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
Putc(c, argname);
} else if (!(isspace(c) || (c == '\\'))) {
Delete(argname);
- Swig_error(Getfile(str), Getline(str), "Illegal character in macro argument name\n");
+ Swig_error(Getfile(argstr), Getline(argstr), "Illegal character in macro argument name\n");
goto macro_error;
}
}
if (Len(argname)) {
/* Check for varargs */
- varargname = Macro_vararg_name(argname, str);
+ varargname = Macro_vararg_name(argname, argstr);
if (varargname) {
Append(arglist, varargname);
Delete(varargname);
@@ -513,7 +513,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
symbols = Getattr(cpp, kpp_symbols);
if ((m1 = Getattr(symbols, macroname))) {
if (!Checkattr(m1, kpp_value, macrovalue)) {
- Swig_error(Getfile(str), Getline(str), "Macro '%s' redefined,\n", macroname);
+ Swig_error(Getfile(macroname), Getline(macroname), "Macro '%s' redefined,\n", macroname);
Swig_error(Getfile(m1), Getline(m1), "previous definition of '%s'.\n", macroname);
goto macro_error;
}