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 hides
problems.  To illustrate this point, enabling this warning by
default revealled 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.

Fixes #1465
Fixes #2389
This commit is contained in:
Olly Betts 2022-10-05 13:23:49 +13:00
commit 06296a7128
7 changed files with 34 additions and 7 deletions

View file

@ -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

View file

@ -1,5 +1,5 @@
%module xxx
/* Note: needs -Wextra to see these warnings */
/* Divide by zero */
#define ZERO 0

View file

@ -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);