[cfe-commits] r150055 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td test/Sema/switch.c

Ted Kremenek kremenek at apple.com
Tue Feb 7 21:08:59 PST 2012


Author: kremenek
Date: Tue Feb  7 23:08:58 2012
New Revision: 150055

URL: http://llvm.org/viewvc/llvm-project?rev=150055&view=rev
Log:
Move -Wcovered-switch-default out of -Wswitch (and -Wall), and make it an opt-in warning.

This is a great warning, but it was observed that a ton of real world code violates
it all the time for (semi-)legitimate reasons.  This warnings is fairly pedantic, which is good,
but not for everyone.  For example, there is a fair amount of idiomatic code out there
that does "default: abort()", and similar idioms.

Addresses <rdar://problem/10814651>.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticGroups.td
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/test/Sema/switch.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=150055&r1=150054&r2=150055&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Feb  7 23:08:58 2012
@@ -184,9 +184,9 @@
 def : DiagGroup<"strict-prototypes">;
 def StrictSelector : DiagGroup<"strict-selector-match">;
 def MethodDuplicate : DiagGroup<"duplicate-method-match">;
-def SwitchEnum     : DiagGroup<"switch-enum">;
 def CoveredSwitchDefault : DiagGroup<"covered-switch-default">;
-def Switch         : DiagGroup<"switch", [CoveredSwitchDefault]>;
+def SwitchEnum     : DiagGroup<"switch-enum">;
+def Switch         : DiagGroup<"switch">;
 def Trigraphs      : DiagGroup<"trigraphs">;
 
 def : DiagGroup<"type-limits">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=150055&r1=150054&r2=150055&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Feb  7 23:08:58 2012
@@ -5064,7 +5064,7 @@
 
 def warn_unreachable_default : Warning<
   "default label in switch which covers all enumeration values">,
-  InGroup<CoveredSwitchDefault>;
+  InGroup<CoveredSwitchDefault>, DefaultIgnore;
 def warn_not_in_enum : Warning<"case value not in enumerated type %0">,
   InGroup<Switch>; 
 def err_typecheck_statement_requires_scalar : Error<

Modified: cfe/trunk/test/Sema/switch.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/switch.c?rev=150055&r1=150054&r2=150055&view=diff
==============================================================================
--- cfe/trunk/test/Sema/switch.c (original)
+++ cfe/trunk/test/Sema/switch.c Tue Feb  7 23:08:58 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum -Wcovered-switch-default %s
 void f (int z) { 
   while (z) { 
     default: z--;            // expected-error {{statement not in switch}}





More information about the cfe-commits mailing list