Change preprocessing error for tokens appearing after #else and #end to warning. Add some missing warning documentation and a couple of warning messages tidy up.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12467 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2011-02-17 21:54:13 +00:00
commit 0913f41fb4
5 changed files with 22 additions and 17 deletions

View file

@ -5,8 +5,8 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.2 (in progress)
===========================
2011-02-16: wsfulton
Preprocessing now errors out if extra tokens appear after #else and #end.
2011-02-17: wsfulton
Preprocessing now warns if extra tokens appear after #else and #end.
2011-02-16: wsfulton
Fix #1653092 Preprocessor does not error out when #elif is missing an expression.

View file

@ -381,8 +381,12 @@ example.i(4) : Syntax error in input.
<ul>
<li>201. Unable to find 'filename'.
<li>202. Could not evaluate expression 'expr'.
<li>201. Unable to find <em>filename</em>.
<li>202. Could not evaluate expression <em>expr</em>.
<li>203. Both includeall and importall are defined: using includeall.
<li>204. CPP #warning, "<em>warning</em>".
<li>205. CPP #error, "<em>error</em>".
<li>206. Unexpected tokens after #<em>directive</em> directive.
</ul>
<H3><a name="Warnings_nn12"></a>14.9.3 C/C++ Parser (300-399)</H3>

View file

@ -69,7 +69,7 @@ c_varargs_neg.i:3: Error: Argument count in %varargs must be positive.
No module name specified using %module or -module.
:::::::::::::::::::::::::::::::: pp_badeval.i :::::::::::::::::::::::::::::::::::
pp_badeval.i:4: Warning 202: Could not evaluate 'FOO==4+'
pp_badeval.i:4: Warning 202: Could not evaluate expression 'FOO==4+'
pp_badeval.i:4: Warning 202: Error: 'Expected an expression'
:::::::::::::::::::::::::::::::: pp_constant.i :::::::::::::::::::::::::::::::::::
@ -89,7 +89,7 @@ pp_defined.i:6: Error: Missing expression for #if.
:::::::::::::::::::::::::::::::: pp_deprecated.i :::::::::::::::::::::::::::::::::::
pp_deprecated.i:4: Warning 101: %extern is deprecated. Use %import instead.
pp_deprecated.i:4: Error: Unable to find 'ext;'
pp_deprecated.i:6: Warning 204: CPP #warning, Print this warning
pp_deprecated.i:6: Warning 204: CPP #warning, "Print this warning".
pp_deprecated.i:8: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing.
:::::::::::::::::::::::::::::::: pp_illegal_argument.i :::::::::::::::::::::::::::::::::::
@ -126,11 +126,11 @@ pp_macro_missing_expression.i:14: Error: Missing expression for #elif.
pp_macro_missing_expression.i:21: Error: Missing expression for #elif.
:::::::::::::::::::::::::::::::: pp_macro_unexpected_tokens.i :::::::::::::::::::::::::::::::::::
pp_macro_unexpected_tokens.i:5: Error: Unexpected tokens after #endif.
pp_macro_unexpected_tokens.i:8: Error: Unexpected tokens after #endif.
pp_macro_unexpected_tokens.i:11: Error: Unexpected tokens after #else.
pp_macro_unexpected_tokens.i:18: Error: Unexpected tokens after #endif.
pp_macro_unexpected_tokens.i:21: Error: Unexpected tokens after #else.
pp_macro_unexpected_tokens.i:5: Warning 206: Unexpected tokens after #endif directive.
pp_macro_unexpected_tokens.i:8: Warning 206: Unexpected tokens after #endif directive.
pp_macro_unexpected_tokens.i:11: Warning 206: Unexpected tokens after #else directive.
pp_macro_unexpected_tokens.i:18: Warning 206: Unexpected tokens after #endif directive.
pp_macro_unexpected_tokens.i:21: Warning 206: Unexpected tokens after #else directive.
:::::::::::::::::::::::::::::::: pp_macro_nargs.i :::::::::::::::::::::::::::::::::::
pp_macro_nargs.i:7: Error: Macro 'foo' expects 2 arguments
@ -240,8 +240,8 @@ cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using
cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'.
:::::::::::::::::::::::::::::::: cpp_macro_locator.i :::::::::::::::::::::::::::::::::::
cpp_macro_locator.i:66: Warning 204: CPP #warning, inline warning message one
cpp_macro_locator.i:96: Warning 204: CPP #warning, an inline warning message 2
cpp_macro_locator.i:66: Warning 204: CPP #warning, "inline warning message one".
cpp_macro_locator.i:96: Warning 204: CPP #warning, "an inline warning message 2".
cpp_macro_locator.i:50: Warning 325: Nested struct not currently supported (Inner ignored)
cpp_macro_locator.i:53: Warning 509: Overloaded method overload1(int const *) effectively ignored,
cpp_macro_locator.i:52: Warning 509: as it is shadowed by overload1(int *).

View file

@ -60,6 +60,7 @@
#define WARN_PP_INCLUDEALL_IMPORTALL 203
#define WARN_PP_CPP_WARNING 204
#define WARN_PP_CPP_ERROR 205
#define WARN_PP_UNEXPECTED_TOKENS 206
/* -- C/C++ Parser -- */

View file

@ -1583,7 +1583,7 @@ String *Preprocessor_parse(String *s) {
} else {
cond_lines[level - 1] = Getline(id);
if (Len(value) != 0)
Swig_error(Getfile(s), Getline(id), "Unexpected tokens after #else.\n");
Swig_warning(WARN_PP_UNEXPECTED_TOKENS, Getfile(s), Getline(id), "Unexpected tokens after #else directive.\n");
if (allow) {
allow = 0;
mask = 0;
@ -1599,7 +1599,7 @@ String *Preprocessor_parse(String *s) {
} else {
if (level < start_level) {
if (Len(value) != 0)
Swig_error(Getfile(s), Getline(id), "Unexpected tokens after #endif.\n");
Swig_warning(WARN_PP_UNEXPECTED_TOKENS, Getfile(s), Getline(id), "Unexpected tokens after #endif directive.\n");
allow = 1;
start_level--;
}
@ -1673,7 +1673,7 @@ String *Preprocessor_parse(String *s) {
}
} else if (Equal(id, kpp_warning)) {
if (allow) {
Swig_warning(WARN_PP_CPP_WARNING, Getfile(s), Getline(id), "CPP #warning, %s\n", value);
Swig_warning(WARN_PP_CPP_WARNING, Getfile(s), Getline(id), "CPP #warning, \"%s\".\n", value);
}
} else if (Equal(id, kpp_error)) {
if (allow) {
@ -1691,7 +1691,7 @@ String *Preprocessor_parse(String *s) {
int sysfile = 0;
String *filename_processed;
if (include_all && import_all) {
Swig_warning(WARN_PP_INCLUDEALL_IMPORTALL, Getfile(s), Getline(id), "Both includeall and importall are defined: using includeall\n");
Swig_warning(WARN_PP_INCLUDEALL_IMPORTALL, Getfile(s), Getline(id), "Both includeall and importall are defined: using includeall.\n");
import_all = 0;
}
filename_processed = Preprocessor_replace(value);