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:
parent
befcd1bf58
commit
06296a7128
7 changed files with 34 additions and 7 deletions
|
|
@ -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)
|
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
|
2022-10-04: olly
|
||||||
#1050 Consistently define SWIG_VERSION both at SWIG-time and in
|
#1050 Consistently define SWIG_VERSION both at SWIG-time and in
|
||||||
the generated wrapper. Best practice remains to check at SWIG-time
|
the generated wrapper. Best practice remains to check at SWIG-time
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,7 @@ General Options
|
||||||
-Wall - Remove all warning suppression, also implies -Wextra
|
-Wall - Remove all warning suppression, also implies -Wextra
|
||||||
-Wallkw - Enable keyword warnings for all the supported languages
|
-Wallkw - Enable keyword warnings for all the supported languages
|
||||||
-Werror - Treat warnings as errors
|
-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
|
-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
|
-xmlout <file> - Write XML version of the parse tree to <file> after normal processing
|
||||||
</pre></div>
|
</pre></div>
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,15 @@ to provide additional diagnostics. These warnings can be turned on using the
|
||||||
</pre>
|
</pre>
|
||||||
</div>
|
</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>
|
<p>
|
||||||
To selectively turn on extra warning messages, you can use the directives and options in the
|
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:
|
previous section--simply add a "+" to all warning numbers. For example:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
%module xxx
|
%module xxx
|
||||||
/* Note: needs -Wextra to see these warnings */
|
|
||||||
|
|
||||||
/* Spaceship operator doesn't seem to be allowed in preprocessor expressions. */
|
/* Spaceship operator doesn't seem to be allowed in preprocessor expressions. */
|
||||||
#if (4 <=> 2) < 0
|
#if (4 <=> 2) < 0
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
%module xxx
|
%module xxx
|
||||||
/* Note: needs -Wextra to see these warnings */
|
|
||||||
|
|
||||||
/* Divide by zero */
|
/* Divide by zero */
|
||||||
#define ZERO 0
|
#define ZERO 0
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ struct Defined {
|
||||||
void defined_not(TYPE);
|
void defined_not(TYPE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !( defined(AAA) \
|
#if !( defined(AAA) &&\
|
||||||
defined(BBB) \\
|
defined(BBB) \\
|
||||||
&& defined(CCC) )
|
&& defined(CCC) )
|
||||||
void bumpf_not(TYPE);
|
void bumpf_not(TYPE);
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,9 @@ extern "C" {
|
||||||
int UseWrapperSuffix = 0; // If 1, append suffix to non-overloaded functions too.
|
int UseWrapperSuffix = 0; // If 1, append suffix to non-overloaded functions too.
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Suppress warning messages for private inheritance, preprocessor evaluation etc...
|
/* Suppress warning messages for private inheritance, etc by default.
|
||||||
WARN_PP_EVALUATION 202
|
These are enabled by command line option -Wextra.
|
||||||
|
|
||||||
WARN_PARSE_PRIVATE_INHERIT 309
|
WARN_PARSE_PRIVATE_INHERIT 309
|
||||||
WARN_PARSE_BUILTIN_NAME 321
|
WARN_PARSE_BUILTIN_NAME 321
|
||||||
WARN_PARSE_REDUNDANT 322
|
WARN_PARSE_REDUNDANT 322
|
||||||
|
|
@ -50,7 +51,7 @@ extern "C" {
|
||||||
WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED 405
|
WARN_TYPE_RVALUE_REF_QUALIFIER_IGNORED 405
|
||||||
WARN_LANG_OVERLOAD_CONST 512
|
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 "C" {
|
||||||
extern String *ModuleName;
|
extern String *ModuleName;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue