This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PR middle-end/40500: Don't make -Wall imply -Wjump-misses-init


When I added -Wjump-misses-init, I had -Wall turn it on.  There was
some discussion back here:
    http://gcc.gnu.org/ml/gcc/2009-06/msg00468.html
I didn't see any clear consensus.

I've thought about it more, and I'm now inclined to think that the new
warning should not be in -Wall.  The main issue I see is that, while
it applies the C++ rules, those rules are not very relevant to C.
What matters in C is whether the value is undefined, not whether it
has an initializer.  In C++ the initializer is routinely at the point
of definition; in C it often is not.

So I now propose to remove -Wjump-misses-init from -Wall.  I plan to
commit this patch in the next couple of days unless I hear objections.

Ian


2009-09-26  Ian Lance Taylor  <iant@google.com>

	PR middle-end/40500
	* c-opts.c (c_common_handle_option): Don't set
	warn_jump_misses_init for -Wall.
	* doc/invoke.texi (Warning Options): Update documentation.


Index: c-opts.c
===================================================================
--- c-opts.c	(revision 152204)
+++ c-opts.c	(working copy)
@@ -397,8 +397,6 @@ c_common_handle_option (size_t scode, co
 	warn_strict_overflow = value;
       warn_array_bounds = value;
       warn_volatile_register_var = value;
-      if (warn_jump_misses_init == -1)
-	warn_jump_misses_init = value;
 
       /* Only warn about unknown pragmas that are not in system
 	 headers.  */
@@ -450,7 +448,7 @@ c_common_handle_option (size_t scode, co
       if (warn_enum_compare == -1 && value)
 	warn_enum_compare = value;
       /* Because C++ always warns about a goto which misses an
-	 initialization, -Wc++-compat turns on -Wgoto-misses-init.  */
+	 initialization, -Wc++-compat turns on -Wjump-misses-init.  */
       if (warn_jump_misses_init == -1 && value)
 	warn_jump_misses_init = value;
       cpp_opts->warn_cxx_operator_names = value;
Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 152204)
+++ doc/invoke.texi	(working copy)
@@ -3025,20 +3025,6 @@ requiring a non-null value by the @code{
 @option{-Wnonnull} is included in @option{-Wall} and @option{-Wformat}.  It
 can be disabled with the @option{-Wno-nonnull} option.
 
-@item -Wjump-misses-init @r{(C, Objective-C only)}
-@opindex Wjump-misses-init
-@opindex Wno-jump-misses-init
-Warn if a @code{goto} statement or a @code{switch} statement jumps
-forward across the initialization of a variable, or jumps backward to a
-label after the variable has been initialized.  This only warns about
-variables which are initialized when they are declared.  This warning is
-only supported for C and Objective C; in C++ this sort of branch is an
-error in any case.
-
-@option{-Wjump-misses-init} is included in @option{-Wall} and
-@option{-Wc++-compat}.  It can be disabled with the
-@option{-Wno-jump-misses-init} option.
-
 @item -Winit-self @r{(C, C++, Objective-C and Objective-C++ only)}
 @opindex Winit-self
 @opindex Wno-init-self
@@ -3850,6 +3836,19 @@ Warn about a comparison between values o
 this warning is enabled by default.  In C this warning is enabled by
 @option{-Wall}.
 
+@item -Wjump-misses-init @r{(C, Objective-C only)}
+@opindex Wjump-misses-init
+@opindex Wno-jump-misses-init
+Warn if a @code{goto} statement or a @code{switch} statement jumps
+forward across the initialization of a variable, or jumps backward to a
+label after the variable has been initialized.  This only warns about
+variables which are initialized when they are declared.  This warning is
+only supported for C and Objective C; in C++ this sort of branch is an
+error in any case.
+
+@option{-Wjump-misses-init} is included in @option{-Wc++-compat}.  It
+can be disabled with the @option{-Wno-jump-misses-init} option.
+
 @item -Wsign-compare
 @opindex Wsign-compare
 @opindex Wno-sign-compare

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]