From: Ted Kremenek Date: Wed, 8 Feb 2012 05:08:58 +0000 (+0000) Subject: Move -Wcovered-switch-default out of -Wswitch (and -Wall), and make it an opt-in... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1a2b8e27135ec72f183dd4510612f6d5d7ee088a;p=clang 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 . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150055 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index f3e2634d64..1a733d28e0 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -184,9 +184,9 @@ def InvalidOffsetof : DiagGroup<"invalid-offsetof">; 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">; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 4366cd4dee..f255b88a8e 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -5064,7 +5064,7 @@ def warn_missing_cases : Warning< def warn_unreachable_default : Warning< "default label in switch which covers all enumeration values">, - InGroup; + InGroup, DefaultIgnore; def warn_not_in_enum : Warning<"case value not in enumerated type %0">, InGroup; def err_typecheck_statement_requires_scalar : Error< diff --git a/test/Sema/switch.c b/test/Sema/switch.c index ea9be59024..8325b4e823 100644 --- a/test/Sema/switch.c +++ b/test/Sema/switch.c @@ -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}}