diff options
author | Phil Edwards <pme@gcc.gnu.org> | 2003-01-24 15:17:26 +0000 |
---|---|---|
committer | Phil Edwards <pme@gcc.gnu.org> | 2003-01-24 15:17:26 +0000 |
commit | 65ca2d606c1420d9a4f76f22c5f07823119fe543 (patch) | |
tree | 869d547d6a351decc78db9dd25b6fc48dbd968be | |
parent | 3de9c088e8349dbf2af82c6ae947e9fe84b356e2 (diff) | |
download | gcc-65ca2d606c1420d9a4f76f22c5f07823119fe543.zip gcc-65ca2d606c1420d9a4f76f22c5f07823119fe543.tar.gz gcc-65ca2d606c1420d9a4f76f22c5f07823119fe543.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/c-decl.c | 4 | ||||
-rw-r--r-- | gcc/c-typeck.c | 2 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 73 | ||||
-rw-r--r-- | gcc/flags.h | 3 | ||||
-rw-r--r-- | gcc/function.c | 5 | ||||
-rw-r--r-- | gcc/stmt.c | 2 | ||||
-rw-r--r-- | gcc/toplev.c | 15 |
8 files changed, 89 insertions, 30 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e71d35e..5e15284 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +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> * ifcvt.c (noce_process_if_block): Re-add check vs X being changed diff --git a/gcc/c-decl.c b/gcc/c-decl.c index c6aa2709..a543931 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -4175,7 +4175,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) { /* Type qualifiers on a function return type are normally 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 definitions in ISO C. FIXME: strictly we shouldn't pedwarn for qualified void return types except on function @@ -6544,7 +6544,7 @@ c_expand_body (fndecl, nested_p, can_defer_p) if (nested_p) 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. */ if (extra_warnings && current_function_returns_value diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 87703a73..4134113 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -3570,7 +3570,7 @@ internal_build_compound_expr (list, first_p) if (! TREE_SIDE_EFFECTS (TREE_VALUE (list))) { /* 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). */ if ((extra_warnings || warn_unused_value) && ! (TREE_CODE (TREE_VALUE (list)) == CONVERT_EXPR diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index a5d6ff0..4d3e0b1 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -212,7 +212,7 @@ in the following sections. @xref{Warning Options,,Options to Request or Suppress Warnings}. @gccoptlist{ -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 -Wconversion -Wno-deprecated-declarations @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 understood by @command{gcc}. If the @option{-v} option is also specified 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 -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 be displayed. @@ -2288,8 +2288,8 @@ To suppress this warning cast the expression to @samp{void}. All the above @option{-Wunused} options combined. In order to get a warning about an unused function parameter, you must -either specify @samp{-W -Wunused} or separately specify -@option{-Wunused-parameter}. +either specify @samp{-Wextra -Wunused} (note that @samp{-Wall} implies +@samp{-Wunused}), or separately specify @option{-Wunused-parameter}. @item -Wuninitialized @opindex Wuninitialized @@ -2402,9 +2402,12 @@ in some cases, and there is no simple way to modify the code to suppress the warning. @table @gcctabopt -@item -W +@item -Wextra @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 @item @@ -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. @item -An unsigned value is compared against zero with @samp{<} or @samp{<=}. +An unsigned value is compared against zero with @samp{<} or @samp{>=}. @item 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. (But don't warn if @option{-Wno-sign-compare} is also specified.) @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. For example, the following code would cause such a warning, because @code{x.h} would be implicitly initialized to zero: @@ -2478,6 +2470,47 @@ For example, the following code would cause such a warning, because struct s @{ int f, g, h; @}; struct s x = @{ 3, 4 @}; @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 @item -Wno-div-by-zero @@ -2678,8 +2711,8 @@ casts like @code{(unsigned) -1}. @cindex signed and unsigned values, comparison warning Warn when a comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned. -This warning is also enabled by @option{-W}; to get the other warnings -of @option{-W} without this warning, use @samp{-W -Wno-sign-compare}. +This warning is also enabled by @option{-Wextra}; to get the other warnings +of @option{-Wextra} without this warning, use @samp{-Wextra -Wno-sign-compare}. @item -Waggregate-return @opindex Waggregate-return diff --git a/gcc/flags.h b/gcc/flags.h index 7ba3f75..8a1998c 100644 --- a/gcc/flags.h +++ b/gcc/flags.h @@ -86,7 +86,8 @@ extern int inhibit_warnings; 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; diff --git a/gcc/function.c b/gcc/function.c index d40801c..c240788 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -6795,9 +6795,10 @@ expand_function_end (filename, line, end_bindings) } /* 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 - -Wunused. */ + -Wunused. Note that -Wall implies -Wunused, so ``-Wall -Wextra'' will + also give these warnings. */ if (warn_unused_parameter > 0 || (warn_unused_parameter < 0 && extra_warnings)) { @@ -2148,7 +2148,7 @@ expand_expr_stmt_value (exp, want_value, maybe_last) if (want_value == -1) 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 last statement in ({...}) where they may be useful. */ if (! want_value diff --git a/gcc/toplev.c b/gcc/toplev.c index b24da96..3399705 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1411,7 +1411,7 @@ int inhibit_warnings = 0; int warn_system_headers = 0; -/* Print various extra warnings. -W. */ +/* Print various extra warnings. -W/-Wextra. */ int extra_warnings = 0; @@ -1506,7 +1506,7 @@ int warn_deprecated_decl = 1; int warn_strict_aliasing; -/* Likewise for -W. */ +/* Like f_options, but for -W. */ 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") }, {"deprecated-declarations", &warn_deprecated_decl, 1, N_("Warn about uses of __attribute__((deprecated)) declarations") }, + {"extra", &extra_warnings, 1, + N_("Print extra (possibly unwanted) warnings") }, {"missing-noreturn", &warn_missing_noreturn, 1, N_("Warn about functions which might be candidates for attribute noreturn") }, {"strict-aliasing", &warn_strict_aliasing, 1, @@ -3743,7 +3745,6 @@ display_help () printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n")); printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n")); printf (_(" -w Suppress warnings\n")); - printf (_(" -W Enable extra warnings\n")); for (i = ARRAY_SIZE (W_options); i--;) { @@ -4117,6 +4118,14 @@ decode_W_option (arg) { 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 return 0; |