According to the discussion in the bugzilla there seems to be
some consensus to activate the warning for -Wextra (I am also
looking into implementing the suggested improvements that may
make it suitable fo r-Wall).   When making this change, I also
noticed that it was not working for -Wc++-compat due to a typo.


Bootstrapped and regression tested for x86_64.

Martin



    c: Enable -Wjump-misses-init in -Wextra and -Wc++-compat [PR87038]
    
    Activate Wjump-misses-init with -Wextra.  Also fix a typo that
    prevented it from being activated with -Wc++compat.
    
            PR c/87038
    
    gcc/c-family/ChangeLog:
            * c.opts (Wjump-misses-init): Fix typo and add -Wextra.
    
    gcc/ChangeLog:
            * doc/invoke.texi (Wjump-misses-init): Mention -Wextra.
    
    gcc/testsuite/ChangeLog:
            * gcc.dg/Wjump-misses-init-3.c: New test.

diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 75b6531860e..4999a132ac9 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -938,7 +938,7 @@ C ObjC C++ ObjC++ CPP(cpp_warn_invalid_utf8) 
CppReason(CPP_W_INVALID_UTF8) Var(w
 Warn about invalid UTF-8 characters.
 
 Wjump-misses-init
-C ObjC Var(warn_jump_misses_init) Warning LangEnabledby(C ObjC,Wc++-compat)
+C ObjC Var(warn_jump_misses_init) Warning LangEnabledBy(C ObjC,Wextra || 
Wc++-compat)
 Warn when a jump misses a variable initialization.
 
 Enum
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 0150ad08879..cd060abc3c4 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -9979,8 +9979,9 @@ variables that 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.
+@option{-Wjump-misses-init} is included in @option{-Wextra} and
+@option{-Wc++-compat}.  It can be disabled with the
+@option{-Wno-jump-misses-init} option.
 
 @opindex Wsign-compare
 @opindex Wno-sign-compare
diff --git a/gcc/testsuite/gcc.dg/Wjump-misses-init-3.c 
b/gcc/testsuite/gcc.dg/Wjump-misses-init-3.c
new file mode 100644
index 00000000000..3bb9360df72
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wjump-misses-init-3.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-Wextra" } */
+
+void f()
+{
+       goto skip;      /* { dg-warning "jump skips variable initialization" } 
*/
+       int i = 1;
+skip:
+}
+

Reply via email to