new -Werror option and fixes for turning on warnings which are normally turned off
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9922 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
d8b7faf4e8
commit
87577ab5e6
4 changed files with 105 additions and 34 deletions
|
|
@ -1,6 +1,19 @@
|
|||
Version 1.3.32 (in progress)
|
||||
============================
|
||||
|
||||
08/31/2007: wsfulton
|
||||
SF #1754967 from James Bigler.
|
||||
- Fix bug in turning on warnings that were turned off by default. Eg 'swig -w+309' will now
|
||||
turn on the normally suppressed warning 309.
|
||||
|
||||
- New -Wextra commandline option which enables the extra warning numbers:
|
||||
202,309,403,512,321,322 (this is the list of warnings that have always been suppressed by
|
||||
default). By specifying -Wextra, all warnings will be turned on, but unlike -Wall,
|
||||
warnings can still be selectively turned on/off using %warnfilter,
|
||||
#pragma SWIG nowarn or further -w commandline options, eg:
|
||||
swig -Wextra -w309
|
||||
will turn on all warnings except 309.
|
||||
|
||||
08/28/2007: wsfulton
|
||||
- New debugging options, -debug-module <n> and -debug-top <n> to display the parse tree at
|
||||
various stages, where <n> is a comma separated list of stages 1-4.For example, to
|
||||
|
|
|
|||
|
|
@ -100,7 +100,8 @@ int foo(double); // Silently ignored.
|
|||
|
||||
<p>
|
||||
The <tt>%warnfilter</tt> directive has the same semantics as other declaration modifiers like
|
||||
<tt>%rename</tt>, <tt>%ignore</tt>, and <tt>%feature</tt>. For example, if you wanted to
|
||||
<tt>%rename</tt>, <tt>%ignore</tt> and <tt>%feature</tt>, see the
|
||||
<a href="Customization.html#features">%feature directive</a> section. For example, if you wanted to
|
||||
suppress a warning for a method in a class hierarchy, you could do this:
|
||||
</p>
|
||||
|
||||
|
|
@ -144,25 +145,21 @@ for a reason---to tell you that something may be <em>broken</em> in
|
|||
your interface. Ignore the warning messages at your own peril.
|
||||
</p>
|
||||
|
||||
<H2><a name="Warnings_nn4"></a>14.3 Enabling additional warnings</H2>
|
||||
|
||||
<H2><a name="Warnings_nn4"></a>14.3 Enabling extra warnings</H2>
|
||||
|
||||
<p>
|
||||
Some warning messages are disabled by default and are generated only
|
||||
to provide additional diagnostics. All warning messages can be
|
||||
enabled using the <tt>-Wall</tt> option. For example:
|
||||
to provide additional diagnostics. These warnings can be turned on using the
|
||||
<tt>-Wextra</tt> option. For example:
|
||||
</p>
|
||||
|
||||
<div class="shell">
|
||||
<pre>
|
||||
% swig -Wall -python example.i
|
||||
% swig -Wextra -python example.i
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
When <tt>-Wall</tt> is used, all other warning filters are disabled.
|
||||
</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:
|
||||
|
|
@ -175,7 +172,7 @@ previous section--simply add a "+" to all warning numbers. For example:
|
|||
</div>
|
||||
|
||||
<p>
|
||||
or
|
||||
or in your interface file use either
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
|
|
@ -199,6 +196,28 @@ Note: selective enabling of warnings with <tt>%warnfilter</tt> overrides any glo
|
|||
made using <tt>-w</tt> or <tt>#pragma</tt>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You can of course also enable all warnings and suppress a select few, for example:
|
||||
</p>
|
||||
|
||||
<div class="shell">
|
||||
<pre>
|
||||
% swig -Wextra -w309,452 example.i
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
The warnings on the right take precedence over the warnings on the left, so in the above example <tt>-Wextra</tt> adds numerous warnings including 452, but then <tt>-w309,452</tt> overrides this and so 452 is suppressesed.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If you would like all warnings to appear, regardless of the warning filters used, then use the <tt>-Wall</tt> option.
|
||||
The <tt>-Wall</tt> option also turns on the extra warnings that <tt>-Wextra</tt> adds, however, it is subtely different.
|
||||
When <tt>-Wall</tt> is used, it also disables all other warning filters,
|
||||
that is, any warnings suppressed or added in <tt>%warnfilter</tt>, <tt>#pragma SWIG nowarn</tt>
|
||||
or the <tt>-w</tt> option.
|
||||
</p>
|
||||
|
||||
<H2><a name="Warnings_nn5"></a>14.4 Issuing a warning message</H2>
|
||||
|
||||
|
||||
|
|
@ -209,7 +228,7 @@ Warning messages can be issued from an interface file using a number of directiv
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%warn "750:This is your last warning!"
|
||||
%warn "900:This is your last warning!"
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -236,7 +255,7 @@ Warning messages can be associated with typemaps using the
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%typemap(in, warning="751:You are really going to regret this") blah * {
|
||||
%typemap(in, warning="901:You are really going to regret this") blah * {
|
||||
...
|
||||
}
|
||||
</pre>
|
||||
|
|
@ -246,15 +265,48 @@ Warning messages can be associated with typemaps using the
|
|||
In this case, the warning message will be printed whenever the typemap is actually used.
|
||||
</p>
|
||||
|
||||
<H2><a name="Warnings_nn6"></a>14.5 Commentary</H2>
|
||||
<H2><a name="Warnings_symbolic_symbols"></a>Symbolic symbols</H2>
|
||||
|
||||
|
||||
<p>
|
||||
The <tt>swigwarn.swg</tt> file that is installed with SWIG contains symbol constants that could also be
|
||||
used in <tt>%warnfilter</tt> and <tt>#pragma SWIG nowarn</tt>.
|
||||
For example this file contains the following line:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%define SWIGWARN_TYPE_UNDEFINED_CLASS 401 %enddef
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
so <tt>SWIGWARN_TYPE_UNDEFINED_CLASS</tt> could be used instead of 401, for example:
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
#pragma SWIG nowarn=SWIGWARN_TYPE_UNDEFINED_CLASS
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<p>
|
||||
or
|
||||
</p>
|
||||
|
||||
<div class="code">
|
||||
<pre>
|
||||
%warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Foo;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<H2><a name="Warnings_nn6"></a>14.5 Commentary</H2>
|
||||
|
||||
<p>
|
||||
The ability to suppress warning messages is really only provided for
|
||||
advanced users and is not recommended in normal use. There are no
|
||||
plans to provide symbolic names or options that identify specific
|
||||
types or groups of warning messages---the numbers must be used
|
||||
explicitly.
|
||||
advanced users and is not recommended in normal use. You are advised
|
||||
to modify your interface to fix the problems highlighted by the warnings
|
||||
wherever possible instead of suppressing warnings.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
@ -294,7 +346,6 @@ example.i(4): Syntax error in input.
|
|||
|
||||
<H2><a name="Warnings_nn9"></a>14.8 Warning number reference</H2>
|
||||
|
||||
|
||||
<H3><a name="Warnings_nn10"></a>14.8.1 Deprecated features (100-199)</H3>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,15 @@ int AddExtern = 0;
|
|||
int NoExcept = 0;
|
||||
int SwigRuntime = 0; // 0 = no option, 1 = -c or -runtime, 2 = -noruntime
|
||||
|
||||
/* Suppress warning messages for private inheritance, preprocessor evaluation etc...
|
||||
WARN_PP_EVALUATION 202
|
||||
WARN_PARSE_PRIVATE_INHERIT 309
|
||||
WARN_TYPE_ABSTRACT 403
|
||||
WARN_LANG_OVERLOAD_CONST 512
|
||||
WARN_PARSE_BUILTIN_NAME 321
|
||||
WARN_PARSE_REDUNDANT 322
|
||||
*/
|
||||
#define EXTRA_WARNINGS "202,309,403,512,321,322"
|
||||
|
||||
extern "C" {
|
||||
extern String *ModuleName;
|
||||
|
|
@ -103,7 +112,7 @@ static const char *usage2 = (const char *) "\
|
|||
|
||||
static const char *usage3 = (const char *) "\
|
||||
-notemplatereduce - Disable reduction of the typedefs in templates\n\
|
||||
-O - Enable the optimizations options: \n\
|
||||
-O - Enable the optimization options: \n\
|
||||
-fastdispatch -fvirtual \n\
|
||||
-o <outfile> - Set name of the output file to <outfile>\n\
|
||||
-oh <headfile> - Set name of the output header file to <headfile>\n\
|
||||
|
|
@ -113,9 +122,10 @@ static const char *usage3 = (const char *) "\
|
|||
-templatereduce - Reduce all the typedefs in templates\n\
|
||||
-v - Run in verbose mode\n\
|
||||
-version - Display SWIG version number\n\
|
||||
-Wall - Enable all warning messages\n\
|
||||
-Wall - Remove all warning suppression, also implies -Wextra\n\
|
||||
-Wallkw - Enable keyword warnings for all the supported languages\n\
|
||||
-Werror - Treat warnings as errors\n\
|
||||
-Wextra - Adds the following additional warnings: " EXTRA_WARNINGS "\n\
|
||||
-w<list> - Suppress/add warning messages, eg -w401,+321 - see Warnings.html\n\
|
||||
-xmlout <file> - Write XML version of the parse tree to <file> after normal processing\n\
|
||||
\n\
|
||||
|
|
@ -673,6 +683,9 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-Werror") == 0) {
|
||||
werror = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-Wextra") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
Swig_warnfilter(EXTRA_WARNINGS, 0);
|
||||
} else if (strncmp(argv[i], "-w", 2) == 0) {
|
||||
Swig_mark_arg(i);
|
||||
Swig_warnfilter(argv[i] + 2, 1);
|
||||
|
|
@ -776,17 +789,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
/* Initialize the SWIG core */
|
||||
Swig_init();
|
||||
|
||||
/* Suppress warning messages for private inheritance, preprocessor
|
||||
evaluation, might be abstract, overloaded const, and ...
|
||||
|
||||
WARN_PP_EVALUATION 202
|
||||
WARN_PARSE_PRIVATE_INHERIT 309
|
||||
WARN_TYPE_ABSTRACT 403
|
||||
WARN_LANG_OVERLOAD_CONST 512
|
||||
WARN_PARSE_BUILTIN_NAME 321
|
||||
WARN_PARSE_REDUNDANT 322
|
||||
*/
|
||||
Swig_warnfilter("202,309,403,512,321,322", 1);
|
||||
// Default warning suppression
|
||||
Swig_warnfilter(EXTRA_WARNINGS, 1);
|
||||
|
||||
// Initialize the preprocessor
|
||||
Preprocessor_init();
|
||||
|
|
|
|||
|
|
@ -89,10 +89,14 @@ void Swig_warning(int wnum, const String_or_char *filename, int line, const char
|
|||
char *f = Char(filter);
|
||||
sprintf(temp, "%d", wnum);
|
||||
while (*f != '\0' && (c = strstr(f, temp))) {
|
||||
if (*(c - 1) == '-')
|
||||
if (*(c - 1) == '-') {
|
||||
wrn = 0; /* Warning disabled */
|
||||
if (*(c - 1) == '+')
|
||||
break;
|
||||
}
|
||||
if (*(c - 1) == '+') {
|
||||
wrn = 1; /* Warning enabled */
|
||||
break;
|
||||
}
|
||||
f += strlen(temp);
|
||||
}
|
||||
}
|
||||
|
|
@ -170,7 +174,6 @@ void Swig_warnfilter(const String_or_char *wlist, int add) {
|
|||
char *c;
|
||||
char *cw;
|
||||
String *s;
|
||||
|
||||
if (!filter)
|
||||
filter = NewStringEmpty();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue