Rename -W to -Wextra.
authorPhil Edwards <pme@gcc.gnu.org>
Fri, 24 Jan 2003 15:17:26 +0000 (15:17 +0000)
committerPhil Edwards <pme@gcc.gnu.org>
Fri, 24 Jan 2003 15:17:26 +0000 (15:17 +0000)
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

gcc/ChangeLog
gcc/c-decl.c
gcc/c-typeck.c
gcc/doc/invoke.texi
gcc/flags.h
gcc/function.c
gcc/stmt.c
gcc/toplev.c

index e71d35ea6aeb27b5ba237c957d448970cbcedfd2..5e15284c2798bf9c0d8042f13b049574efb750eb 100644 (file)
@@ -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
index c6aa2709dcc7554151e18c99312bf36f3dee1229..a5439316d2e54d89b16a1522be902f29db76da1b 100644 (file)
@@ -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
index 87703a730795a0e8b01d389f9838881f4da51de6..4134113557a39663b45389272626f0f4c72234e6 100644 (file)
@@ -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
index a5d6ff0cb5d6f4748f52f8f6228cf8f9568a9db5..4d3e0b1851e5aad43cf96d42a1e2d5b60cbe3cce 100644 (file)
@@ -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
@@ -2458,17 +2461,6 @@ A comparison between signed and unsigned values could produce an
 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
@@ -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
index 7ba3f7550a7ddff9914c8acc38e2df800818f3a6..8a1998c5a8496c1469053254c7d39fb1ff7770ff 100644 (file)
@@ -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;
 
index d40801c40782f12cfafc3fec31d2c2e10a139e99..c240788e30a8746332410248061fae94ee257b35 100644 (file)
@@ -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))
     {
index 043b752cb4539ed8e6b859c4d61541fba3538eaa..adc7114c7e2634c0ca16cccdf66b9c4c62eb5536 100644 (file)
@@ -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
index b24da96cba3914838e9ef90e8247d02070bc3ed5..33997052b1b893eb2d65354229f19e0386534086 100644 (file)
@@ -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;