summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.current17
-rw-r--r--Doc/Manual/SWIG.html2
-rw-r--r--Doc/Manual/Warnings.html9
-rw-r--r--Examples/test-suite/errors/cpp_pp_expressions_bad.i2
-rw-r--r--Examples/test-suite/errors/pp_expressions_bad.i2
-rw-r--r--Examples/test-suite/preproc_defined.i2
-rw-r--r--Source/Modules/main.cxx7
7 files changed, 34 insertions, 7 deletions
diff --git a/CHANGES.current b/CHANGES.current
index 921441645..5d79c9084 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -7,6 +7,23 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.0 (in progress)
===========================
+2022-10-05: olly
+ #1465 Report errors in preprocessor expressions by default
+
+ Until now SWIG quietly ignored such errors unless -Wextra (or -Wall
+ which implies -Wextra) was passed, but this is unhelpful as it tends
+ to hide genuine problems. To illustrate this point, enabling this
+ warning by default revealed a typo in the preproc_defined.i
+ testcase in SWIG's own testsuite.
+
+ If you really don't want to see this warning, you can suppress it
+ with command line option -w202 or by using this in your interface
+ file:
+
+ %warnfilter(SWIGWARN_PP_EVALUATION);
+
+ Both will work with older versions of SWIG too.
+
2022-10-04: olly
#1050 Consistently define SWIG_VERSION both at SWIG-time and in
the generated wrapper. Best practice remains to check at SWIG-time
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index b7021c468..e3e11841d 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -219,7 +219,7 @@ General Options
-Wall - Remove all warning suppression, also implies -Wextra
-Wallkw - Enable keyword warnings for all the supported languages
-Werror - Treat warnings as errors
- -Wextra - Adds the following additional warnings: 202,309,403,405,512,321,322
+ -Wextra - Adds the following additional warnings: 309,403,405,512,321,322
-w<list> - Suppress/add warning messages, eg -w401,+321 - see Warnings.html
-xmlout <file> - Write XML version of the parse tree to <file> after normal processing
</pre></div>
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 6140dd21a..b20b69cef 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -165,6 +165,15 @@ to provide additional diagnostics. These warnings can be turned on using the
</div>
<p>
+Preprocessor warning 202 ("Could not evaluate expression <em>expr</em>.") was
+formally off by default and enabled by <tt>-Wextra</tt>, but since SWIG 4.1.0
+this warning is on by default because suppressing it tends to hide genuine
+problems. If you really don't want to see it, you can suppress it with
+<tt>-w202</tt> or using <tt>%warnfilter</tt> as described below. Both will work
+with older versions of SWIG too.
+</p>
+
+<p>
To selectively turn on extra warning messages, you can use the directives and options in the
previous section--simply add a "+" to all warning numbers. For example:
</p>
diff --git a/Examples/test-suite/errors/cpp_pp_expressions_bad.i b/Examples/test-suite/errors/cpp_pp_expressions_bad.i
index c95b9bfc4..2f71232fe 100644
--- a/Examples/test-suite/errors/cpp_pp_expressions_bad.i
+++ b/Examples/test-suite/errors/cpp_pp_expressions_bad.i
@@ -1,5 +1,5 @@
%module xxx
-/* Note: needs -Wextra to see these warnings */
+
/* Spaceship operator doesn't seem to be allowed in preprocessor expressions. */
#if (4 <=> 2) < 0
diff --git a/Examples/test-suite/errors/pp_expressions_bad.i b/Examples/test-suite/errors/pp_expressions_bad.i
index 0e67c78f8..eea178388 100644
--- a/Examples/test-suite/errors/pp_expressions_bad.i
+++ b/Examples/test-suite/errors/pp_expressions_bad.i
@@ -1,5 +1,5 @@
%module xxx
-/* Note: needs -Wextra to see these warnings */
+
/* Divide by zero */
#define ZERO 0
diff --git a/Examples/test-suite/preproc_defined.i b/Examples/test-suite/preproc_defined.i
index e1958515d..5ebf0a099 100644
--- a/Examples/test-suite/preproc_defined.i
+++ b/Examples/test-suite/preproc_defined.i
@@ -86,7 +86,7 @@ struct Defined {
void defined_not(TYPE);
#endif
-#if !( defined(AAA) \
+#if !( defined(AAA) &&\
defined(BBB) \\
&& defined(CCC) )
void bumpf_not(TYPE);
diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
index 44d30e893..8a3259db8 100644
--- a/Source/Modules/main.cxx
+++ b/Source/Modules/main.cxx
@@ -41,8 +41,9 @@ extern "C" {
int UseWrapperSuffix = 0; // If 1, append suffix to non-overloaded functions too.
}
-/* Suppress warning messages for private inheritance, preprocessor evaluation etc...
- WARN_PP_EVALUATION 202
+/* Suppress warning messages for private inheritance, etc by default.
+ These are enabled by command line option -Wextra.
+
WARN_PARSE_PRIVATE_INHERIT 309
WARN_PARSE_BUILTIN_NAME 321
WARN_PARSE_REDUNDANT 322
@@ -50,7 +51,7 @@ extern "C" {
WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED 405
WARN_LANG_OVERLOAD_CONST 512
*/
-#define EXTRA_WARNINGS "202,309,403,405,512,321,322"
+#define EXTRA_WARNINGS "309,403,405,512,321,322"
extern "C" {
extern String *ModuleName;