Commit 65ca2d60 by Phil Edwards

Rename -W to -Wextra.

2003-01-24  Phil Edwards  <pme@gcc.gnu.org>

	Rename -W to -Wextra.
	* c-decl.c:  Update comments.
	* c-typeck.c:  Likewise.
	* flags.h:  Likewise.
	* function.c:  Likewise.
	* stmt.c:  Likewise.
	* toplev.c:  Update comments.
	(W_options):  Add 'extra'.
	(display_help):  Remove '-W'.
	(decode_W_option):  Special warn_uninitialized treatment in the case
	of -Wextra.
	* doc/invoke.texi:  Update with new entries.

From-SVN: r61696
parent 3de9c088
2003-01-24 Phil Edwards <pme@gcc.gnu.org>
Rename -W to -Wextra.
* c-decl.c: Update comments.
* c-typeck.c: Likewise.
* flags.h: Likewise.
* function.c: Likewise.
* stmt.c: Likewise.
* toplev.c: Update comments.
(W_options): Add 'extra'.
(display_help): Remove '-W'.
(decode_W_option): Special warn_uninitialized treatment in the case
of -Wextra.
* doc/invoke.texi: Update with new entries.
2003-01-23 Richard Henderson <rth@redhat.com> 2003-01-23 Richard Henderson <rth@redhat.com>
* ifcvt.c (noce_process_if_block): Re-add check vs X being changed * ifcvt.c (noce_process_if_block): Re-add check vs X being changed
......
...@@ -4175,7 +4175,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) ...@@ -4175,7 +4175,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized)
{ {
/* Type qualifiers on a function return type are normally /* Type qualifiers on a function return type are normally
permitted by the standard but have no effect, so give a permitted by the standard but have no effect, so give a
warning at -W. Qualifiers on a void return type have warning at -Wextra. Qualifiers on a void return type have
meaning as a GNU extension, and are banned on function meaning as a GNU extension, and are banned on function
definitions in ISO C. FIXME: strictly we shouldn't definitions in ISO C. FIXME: strictly we shouldn't
pedwarn for qualified void return types except on function pedwarn for qualified void return types except on function
...@@ -6544,7 +6544,7 @@ c_expand_body (fndecl, nested_p, can_defer_p) ...@@ -6544,7 +6544,7 @@ c_expand_body (fndecl, nested_p, can_defer_p)
if (nested_p) if (nested_p)
ggc_pop_context (); ggc_pop_context ();
/* With just -W, complain only if function returns both with /* With just -Wextra, complain only if function returns both with
and without a value. */ and without a value. */
if (extra_warnings if (extra_warnings
&& current_function_returns_value && current_function_returns_value
......
...@@ -3570,7 +3570,7 @@ internal_build_compound_expr (list, first_p) ...@@ -3570,7 +3570,7 @@ internal_build_compound_expr (list, first_p)
if (! TREE_SIDE_EFFECTS (TREE_VALUE (list))) if (! TREE_SIDE_EFFECTS (TREE_VALUE (list)))
{ {
/* The left-hand operand of a comma expression is like an expression /* The left-hand operand of a comma expression is like an expression
statement: with -W or -Wunused, we should warn if it doesn't have statement: with -Wextra or -Wunused, we should warn if it doesn't have
any side-effects, unless it was explicitly cast to (void). */ any side-effects, unless it was explicitly cast to (void). */
if ((extra_warnings || warn_unused_value) if ((extra_warnings || warn_unused_value)
&& ! (TREE_CODE (TREE_VALUE (list)) == CONVERT_EXPR && ! (TREE_CODE (TREE_VALUE (list)) == CONVERT_EXPR
......
...@@ -212,7 +212,7 @@ in the following sections. ...@@ -212,7 +212,7 @@ in the following sections.
@xref{Warning Options,,Options to Request or Suppress Warnings}. @xref{Warning Options,,Options to Request or Suppress Warnings}.
@gccoptlist{ @gccoptlist{
-fsyntax-only -pedantic -pedantic-errors @gol -fsyntax-only -pedantic -pedantic-errors @gol
-w -W -Wall -Waggregate-return @gol -w -Wextra -Wall -Waggregate-return @gol
-Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol
-Wconversion -Wno-deprecated-declarations @gol -Wconversion -Wno-deprecated-declarations @gol
-Wdisabled-optimization -Wno-div-by-zero -Werror @gol -Wdisabled-optimization -Wno-div-by-zero -Werror @gol
...@@ -950,7 +950,7 @@ Print (on the standard output) a description of the command line options ...@@ -950,7 +950,7 @@ Print (on the standard output) a description of the command line options
understood by @command{gcc}. If the @option{-v} option is also specified understood by @command{gcc}. If the @option{-v} option is also specified
then @option{--help} will also be passed on to the various processes then @option{--help} will also be passed on to the various processes
invoked by @command{gcc}, so that they can display the command line options invoked by @command{gcc}, so that they can display the command line options
they accept. If the @option{-W} option is also specified then command they accept. If the @option{-Wextra} option is also specified then command
line options which have no documentation associated with them will also line options which have no documentation associated with them will also
be displayed. be displayed.
...@@ -2288,8 +2288,8 @@ To suppress this warning cast the expression to @samp{void}. ...@@ -2288,8 +2288,8 @@ To suppress this warning cast the expression to @samp{void}.
All the above @option{-Wunused} options combined. All the above @option{-Wunused} options combined.
In order to get a warning about an unused function parameter, you must In order to get a warning about an unused function parameter, you must
either specify @samp{-W -Wunused} or separately specify either specify @samp{-Wextra -Wunused} (note that @samp{-Wall} implies
@option{-Wunused-parameter}. @samp{-Wunused}), or separately specify @option{-Wunused-parameter}.
@item -Wuninitialized @item -Wuninitialized
@opindex Wuninitialized @opindex Wuninitialized
...@@ -2402,9 +2402,12 @@ in some cases, and there is no simple way to modify the code to suppress ...@@ -2402,9 +2402,12 @@ in some cases, and there is no simple way to modify the code to suppress
the warning. the warning.
@table @gcctabopt @table @gcctabopt
@item -W @item -Wextra
@opindex W @opindex W
Print extra warning messages for these events: @opindex Wextra
(This option used to be called @option{-W}. The older name is still
supported, but the newer name is more descriptive.) Print extra warning
messages for these events:
@itemize @bullet @itemize @bullet
@item @item
...@@ -2431,7 +2434,7 @@ For example, an expression such as @samp{x[i,j]} will cause a warning, ...@@ -2431,7 +2434,7 @@ For example, an expression such as @samp{x[i,j]} will cause a warning,
but @samp{x[(void)i,j]} will not. but @samp{x[(void)i,j]} will not.
@item @item
An unsigned value is compared against zero with @samp{<} or @samp{<=}. An unsigned value is compared against zero with @samp{<} or @samp{>=}.
@item @item
A comparison like @samp{x<=y<=z} appears; this is equivalent to A comparison like @samp{x<=y<=z} appears; this is equivalent to
...@@ -2459,17 +2462,6 @@ incorrect result when the signed value is converted to unsigned. ...@@ -2459,17 +2462,6 @@ incorrect result when the signed value is converted to unsigned.
(But don't warn if @option{-Wno-sign-compare} is also specified.) (But don't warn if @option{-Wno-sign-compare} is also specified.)
@item @item
An aggregate has a partly bracketed initializer.
For example, the following code would evoke such a warning,
because braces are missing around the initializer for @code{x.h}:
@smallexample
struct s @{ int f, g; @};
struct t @{ struct s h; int i; @};
struct t x = @{ 1, 2, 3 @};
@end smallexample
@item
An aggregate has an initializer which does not initialize all members. An aggregate has an initializer which does not initialize all members.
For example, the following code would cause such a warning, because For example, the following code would cause such a warning, because
@code{x.h} would be implicitly initialized to zero: @code{x.h} would be implicitly initialized to zero:
...@@ -2478,6 +2470,47 @@ For example, the following code would cause such a warning, because ...@@ -2478,6 +2470,47 @@ For example, the following code would cause such a warning, because
struct s @{ int f, g, h; @}; struct s @{ int f, g, h; @};
struct s x = @{ 3, 4 @}; struct s x = @{ 3, 4 @};
@end smallexample @end smallexample
@item
A function parameter is declared without a type specifier in K&R-style
functions:
@smallexample
void foo(bar) @{ @}
@end smallexample
@item
An empty body occurs in an @samp{if} or @samp{else} statement.
@item
A pointer is compared against integer zero with @samp{<}, @samp{<=},
@samp{>}, or @samp{>=}.
@item
A variable might be changed by @samp{longjmp} or @samp{vfork}.
@item
Any of several floating-point events that often indicate errors, such as
overflow, underflow, loss of precision, etc.
@item @r{(C++ only)}
An enumerator and a non-enumerator both appear in a conditional expression.
@item @r{(C++ only)}
A non-static reference or non-static @samp{const} member appears in a
class without constructors.
@item @r{(C++ only)}
Ambiguous virtual bases.
@item @r{(C++ only)}
Subscripting an array which has been declared @samp{register}.
@item @r{(C++ only)}
Taking the address of a variable which has been declared @samp{register}.
@item @r{(C++ only)}
A base class is not initialized in a derived class' copy constrcutor.
@end itemize @end itemize
@item -Wno-div-by-zero @item -Wno-div-by-zero
...@@ -2678,8 +2711,8 @@ casts like @code{(unsigned) -1}. ...@@ -2678,8 +2711,8 @@ casts like @code{(unsigned) -1}.
@cindex signed and unsigned values, comparison warning @cindex signed and unsigned values, comparison warning
Warn when a comparison between signed and unsigned values could produce Warn when a comparison between signed and unsigned values could produce
an incorrect result when the signed value is converted to unsigned. an incorrect result when the signed value is converted to unsigned.
This warning is also enabled by @option{-W}; to get the other warnings This warning is also enabled by @option{-Wextra}; to get the other warnings
of @option{-W} without this warning, use @samp{-W -Wno-sign-compare}. of @option{-Wextra} without this warning, use @samp{-Wextra -Wno-sign-compare}.
@item -Waggregate-return @item -Waggregate-return
@opindex Waggregate-return @opindex Waggregate-return
......
...@@ -86,7 +86,8 @@ extern int inhibit_warnings; ...@@ -86,7 +86,8 @@ extern int inhibit_warnings;
extern int warn_system_headers; extern int warn_system_headers;
/* Do print extra warnings (such as for uninitialized variables). -W. */ /* Do print extra warnings (such as for uninitialized variables).
-W/-Wextra. */
extern int extra_warnings; extern int extra_warnings;
......
...@@ -6795,9 +6795,10 @@ expand_function_end (filename, line, end_bindings) ...@@ -6795,9 +6795,10 @@ expand_function_end (filename, line, end_bindings)
} }
/* Warn about unused parms if extra warnings were specified. */ /* Warn about unused parms if extra warnings were specified. */
/* Either ``-W -Wunused'' or ``-Wunused-parameter'' enables this /* Either ``-Wextra -Wunused'' or ``-Wunused-parameter'' enables this
warning. WARN_UNUSED_PARAMETER is negative when set by warning. WARN_UNUSED_PARAMETER is negative when set by
-Wunused. */ -Wunused. Note that -Wall implies -Wunused, so ``-Wall -Wextra'' will
also give these warnings. */
if (warn_unused_parameter > 0 if (warn_unused_parameter > 0
|| (warn_unused_parameter < 0 && extra_warnings)) || (warn_unused_parameter < 0 && extra_warnings))
{ {
......
...@@ -2148,7 +2148,7 @@ expand_expr_stmt_value (exp, want_value, maybe_last) ...@@ -2148,7 +2148,7 @@ expand_expr_stmt_value (exp, want_value, maybe_last)
if (want_value == -1) if (want_value == -1)
want_value = expr_stmts_for_value != 0; want_value = expr_stmts_for_value != 0;
/* If -W, warn about statements with no side effects, /* If -Wextra, warn about statements with no side effects,
except for an explicit cast to void (e.g. for assert()), and except for an explicit cast to void (e.g. for assert()), and
except for last statement in ({...}) where they may be useful. */ except for last statement in ({...}) where they may be useful. */
if (! want_value if (! want_value
......
...@@ -1411,7 +1411,7 @@ int inhibit_warnings = 0; ...@@ -1411,7 +1411,7 @@ int inhibit_warnings = 0;
int warn_system_headers = 0; int warn_system_headers = 0;
/* Print various extra warnings. -W. */ /* Print various extra warnings. -W/-Wextra. */
int extra_warnings = 0; int extra_warnings = 0;
...@@ -1506,7 +1506,7 @@ int warn_deprecated_decl = 1; ...@@ -1506,7 +1506,7 @@ int warn_deprecated_decl = 1;
int warn_strict_aliasing; int warn_strict_aliasing;
/* Likewise for -W. */ /* Like f_options, but for -W. */
static const lang_independent_options W_options[] = static const lang_independent_options W_options[] =
{ {
...@@ -1550,6 +1550,8 @@ static const lang_independent_options W_options[] = ...@@ -1550,6 +1550,8 @@ static const lang_independent_options W_options[] =
N_("Warn when an optimization pass is disabled") }, N_("Warn when an optimization pass is disabled") },
{"deprecated-declarations", &warn_deprecated_decl, 1, {"deprecated-declarations", &warn_deprecated_decl, 1,
N_("Warn about uses of __attribute__((deprecated)) declarations") }, N_("Warn about uses of __attribute__((deprecated)) declarations") },
{"extra", &extra_warnings, 1,
N_("Print extra (possibly unwanted) warnings") },
{"missing-noreturn", &warn_missing_noreturn, 1, {"missing-noreturn", &warn_missing_noreturn, 1,
N_("Warn about functions which might be candidates for attribute noreturn") }, N_("Warn about functions which might be candidates for attribute noreturn") },
{"strict-aliasing", &warn_strict_aliasing, 1, {"strict-aliasing", &warn_strict_aliasing, 1,
...@@ -3743,7 +3745,6 @@ display_help () ...@@ -3743,7 +3745,6 @@ display_help ()
printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n")); printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n")); printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
printf (_(" -w Suppress warnings\n")); printf (_(" -w Suppress warnings\n"));
printf (_(" -W Enable extra warnings\n"));
for (i = ARRAY_SIZE (W_options); i--;) for (i = ARRAY_SIZE (W_options); i--;)
{ {
...@@ -4117,6 +4118,14 @@ decode_W_option (arg) ...@@ -4117,6 +4118,14 @@ decode_W_option (arg)
{ {
set_Wunused (0); set_Wunused (0);
} }
else if (!strcmp (arg, "extra"))
{
/* We save the value of warn_uninitialized, since if they put
-Wuninitialized on the command line, we need to generate a
warning about not using it without also specifying -O. */
if (warn_uninitialized != 1)
warn_uninitialized = 2;
}
else else
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment