I'm concerned about the number of false positives for this warning, and
judging by previous discussions, I'm not alone in this. This patch
limits it to level 1 (any comment before the case label disables the
warning) for cases where the user specified no explicit level. It'll
still generate enough noise that people will be aware of it and can
choose whether to use a higher level or not.
Bootstrapped and tested on x86_64-linux. Ok?
Bernd
c-family/
* c.opt (Wimplicit-fallthrough=): Default to 1.
gcc/
* common.opt (Wimplicit-fallthrough=): Default to 1.
* doc/invoke.texi (-Wextra, -Wimplicit-fallthrough): Adjust
documentation.
testsuite/
* c-c++-comon/Wimplicit-fallthrough-1.c: Specify level for
-Wimplicit-fallthrough
* c-c++-comon/Wimplicit-fallthrough-10.c: Likewise.
* c-c++-comon/Wimplicit-fallthrough-12.c: Likewise.
* c-c++-comon/Wimplicit-fallthrough-16.c: Likewise.
* c-c++-comon/Wimplicit-fallthrough-19.c: Likewise.
* c-c++-comon/Wimplicit-fallthrough-2.c: Likewise.
* c-c++-comon/Wimplicit-fallthrough-22.c: Likewise.
* c-c++-comon/Wimplicit-fallthrough-25.c: Likewise.
* c-c++-comon/Wimplicit-fallthrough-26.c: Likewise.
* c-c++-comon/Wimplicit-fallthrough-3.c: Likewise.
* c-c++-comon/Wimplicit-fallthrough-4.c: Likewise.
* c-c++-comon/Wimplicit-fallthrough-5.c: Likewise.
* c-c++-comon/Wimplicit-fallthrough-7.c: Likewise.
* c-c++-comon/Wimplicit-fallthrough-8.c: Likewise.
* c-c++-comon/attr-fallthrough-1.c: Likewise.
* g++.dg/cpp0x/fallthrough1.C: Likewise.
* objc.dg/Wimplicit-fallthrough-1.m: Likewise.
Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt (revision 241233)
+++ gcc/c-family/c.opt (working copy)
@@ -541,7 +541,7 @@ C ObjC Var(warn_implicit) Warning LangEn
Warn about implicit declarations.
Wimplicit-fallthrough=
-LangEnabledBy(C ObjC C++ ObjC++,Wextra,3,0)
+LangEnabledBy(C ObjC C++ ObjC++,Wextra,1,0)
; in common.opt
Wdouble-promotion
Index: gcc/common.opt
===================================================================
--- gcc/common.opt (revision 241233)
+++ gcc/common.opt (working copy)
@@ -602,7 +602,7 @@ Common Var(warn_hsa) Init(1) Warning
Warn when a function cannot be expanded to HSAIL.
Wimplicit-fallthrough
-Common Alias(Wimplicit-fallthrough=,3,0) Warning
+Common Alias(Wimplicit-fallthrough=,1,0) Warning
Wimplicit-fallthrough=
Common Var(warn_implicit_fallthrough) RejectNegative Joined UInteger Warning
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi (revision 241233)
+++ gcc/doc/invoke.texi (working copy)
@@ -3735,7 +3735,7 @@ name is still supported, but the newer n
@gccoptlist{-Wclobbered @gol
-Wempty-body @gol
-Wignored-qualifiers @gol
--Wimplicit-fallthrough=3 @gol
+-Wimplicit-fallthrough=1 @gol
-Wmissing-field-initializers @gol
-Wmissing-parameter-type @r{(C only)} @gol
-Wold-style-declaration @r{(C only)} @gol
@@ -4107,7 +4107,7 @@ This warning is enabled by @option{-Wall
@item -Wimplicit-fallthrough
@opindex Wimplicit-fallthrough
@opindex Wno-implicit-fallthrough
-@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=3}
+@option{-Wimplicit-fallthrough} is the same as @option{-Wimplicit-fallthrough=1}
and @option{-Wno-implicit-fallthrough} is the same as
@option{-Wimplicit-fallthrough=0}.
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-1.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-1.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-1.c (working copy)
@@ -1,6 +1,6 @@
/* PR c/7652 */
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough" } */
+/* { dg-options "-Wimplicit-fallthrough=3" } */
/* Test taken from
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0188r0.pdf>. */
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-10.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-10.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-10.c (working copy)
@@ -1,6 +1,6 @@
/* PR c/7652 */
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough" } */
+/* { dg-options "-Wimplicit-fallthrough=3" } */
extern void bar (int);
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-12.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-12.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-12.c (working copy)
@@ -1,6 +1,6 @@
/* PR c/7652 */
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough -O2" } */
+/* { dg-options "-Wimplicit-fallthrough=3 -O2" } */
/* Don't let optimizations preclude the warning. */
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-16.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-16.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-16.c (working copy)
@@ -1,6 +1,6 @@
/* PR c/7652 */
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough" } */
+/* { dg-options "-Wimplicit-fallthrough=3" } */
/* Another nested switch, and with an initialization on top. Check that
we do warn here. */
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-19.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-19.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-19.c (working copy)
@@ -1,6 +1,6 @@
/* PR c/7652 */
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough" } */
+/* { dg-options "-Wimplicit-fallthrough=3" } */
/* Testing non-case labels. */
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-2.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-2.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-2.c (working copy)
@@ -1,6 +1,6 @@
/* PR c/7652 */
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough" } */
+/* { dg-options "-Wimplicit-fallthrough=3" } */
extern void bar (int);
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-22.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-22.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-22.c (working copy)
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough" } */
+/* { dg-options "-Wimplicit-fallthrough=3" } */
void bar (int);
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-25.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-25.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-25.c (working copy)
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-Wextra" } */
+/* { dg-options "-Wimplicit-fallthrough=3" } */
void bar (int);
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-26.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-26.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-26.c (working copy)
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough" } */
+/* { dg-options "-Wimplicit-fallthrough=3" } */
void bar (int);
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-3.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-3.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-3.c (working copy)
@@ -1,6 +1,6 @@
/* PR c/7652 */
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough" } */
+/* { dg-options "-Wimplicit-fallthrough=3" } */
extern void bar (int);
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-4.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-4.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-4.c (working copy)
@@ -1,6 +1,6 @@
/* PR c/7652 */
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough" } */
+/* { dg-options "-Wimplicit-fallthrough=3" } */
extern void bar (int);
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-5.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-5.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-5.c (working copy)
@@ -1,6 +1,6 @@
/* PR c/7652 */
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough" } */
+/* { dg-options "-Wimplicit-fallthrough=2" } */
extern void bar (int);
extern void die (void) __attribute__((noreturn));
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-7.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-7.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-7.c (working copy)
@@ -1,6 +1,6 @@
/* PR c/7652 */
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough" } */
+/* { dg-options "-Wimplicit-fallthrough=3" } */
extern void bar (int);
extern int bar2 (void);
Index: gcc/testsuite/c-c++-common/Wimplicit-fallthrough-8.c
===================================================================
--- gcc/testsuite/c-c++-common/Wimplicit-fallthrough-8.c (revision 241233)
+++ gcc/testsuite/c-c++-common/Wimplicit-fallthrough-8.c (working copy)
@@ -1,6 +1,6 @@
/* PR c/7652 */
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough" } */
+/* { dg-options "-Wimplicit-fallthrough=3" } */
extern void grace (int);
Index: gcc/testsuite/c-c++-common/attr-fallthrough-1.c
===================================================================
--- gcc/testsuite/c-c++-common/attr-fallthrough-1.c (revision 241233)
+++ gcc/testsuite/c-c++-common/attr-fallthrough-1.c (working copy)
@@ -1,6 +1,6 @@
/* PR c/7652 */
/* { dg-do compile } */
-/* { dg-options "-Wall -Wextra -Wpedantic" } */
+/* { dg-options "-Wall -Wimplicit-fallthrough=3 -Wpedantic" } */
extern void bar (int);
void
Index: gcc/testsuite/g++.dg/cpp0x/fallthrough1.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/fallthrough1.C (revision 241233)
+++ gcc/testsuite/g++.dg/cpp0x/fallthrough1.C (working copy)
@@ -1,6 +1,6 @@
// PR c/7652
// { dg-do compile { target c++11 } }
-// { dg-options "-Wextra -Wall -Wpedantic" }
+// { dg-options "-Wimplicit-fallthrough=3 -Wall -Wpedantic" }
extern void bar (int);
void
Index: gcc/testsuite/objc.dg/Wimplicit-fallthrough-1.m
===================================================================
--- gcc/testsuite/objc.dg/Wimplicit-fallthrough-1.m (revision 241233)
+++ gcc/testsuite/objc.dg/Wimplicit-fallthrough-1.m (working copy)
@@ -1,6 +1,6 @@
/* PR c/7652 */
/* { dg-do compile } */
-/* { dg-options "-Wimplicit-fallthrough" } */
+/* { dg-options "-Wimplicit-fallthrough=3" } */
/* Test taken from
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0188r0.pdf>. */