From 0913f41fb436fdc82ccd24ac92c4d60b089fe74f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Feb 2011 21:54:13 +0000 Subject: [PATCH] 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 --- CHANGES.current | 4 ++-- Doc/Manual/Warnings.html | 8 ++++++-- Examples/test-suite/errors/expected.log | 18 +++++++++--------- Source/Include/swigwarn.h | 1 + Source/Preprocessor/cpp.c | 8 ++++---- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index d716a96c6..5f2d1c8d3 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -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. diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index fadcd64a4..60552b97a 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -381,8 +381,12 @@ example.i(4) : Syntax error in input.

14.9.3 C/C++ Parser (300-399)

diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log index 6dcfec54c..53943506d 100644 --- a/Examples/test-suite/errors/expected.log +++ b/Examples/test-suite/errors/expected.log @@ -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 *). diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 9c5c3be74..9f1df25d2 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -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 -- */ diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index f5ae8fda8..752c95e57 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -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);