[cfe-commits] r148648 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td test/SemaCXX/switch.cpp
David Blaikie
dblaikie at gmail.com
Sat Jan 21 17:58:03 PST 2012
Author: dblaikie
Date: Sat Jan 21 19:58:03 2012
New Revision: 148648
URL: http://llvm.org/viewvc/llvm-project?rev=148648&view=rev
Log:
Move -Wswitch-enum to -Wswitch
This matches GCC's documented (& actual) behavior. What Clang had implemented
as -Wswitch-enum was actually GCC's -Wswitch behavior. -Wswitch is on by
default (part of -Wall) and warns if a switch-over-enum, without a default
case, covers all enum values.
-Wswitch-enum, on the other hand, does not have the default clause and should
fire even in the presence of a default. This warning is off by default.
With this change the -Wswitch-enum flag is off-by-default in Clang but has no
functionality at the moment. I'll add that in a future commit.
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/SemaCXX/switch.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=148648&r1=148647&r2=148648&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Sat Jan 21 19:58:03 2012
@@ -178,9 +178,9 @@
def : DiagGroup<"strict-prototypes">;
def StrictSelector : DiagGroup<"strict-selector-match">;
def MethodDuplicate : DiagGroup<"duplicate-method-match">;
+def SwitchEnum : DiagGroup<"switch-enum">;
def SwitchEnumRedundantDefault : DiagGroup<"switch-enum-redundant-default">;
-def SwitchEnum : DiagGroup<"switch-enum", [SwitchEnumRedundantDefault]>;
-def Switch : DiagGroup<"switch", [SwitchEnum]>;
+def Switch : DiagGroup<"switch", [SwitchEnumRedundantDefault]>;
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=148648&r1=148647&r2=148648&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Jan 21 19:58:03 2012
@@ -4946,22 +4946,22 @@
def warn_missing_case_for_condition :
Warning<"no case matching constant switch condition '%0'">;
def warn_missing_case1 : Warning<"enumeration value %0 not handled in switch">,
- InGroup<SwitchEnum>;
+ InGroup<Switch>;
def warn_missing_case2 : Warning<
"enumeration values %0 and %1 not handled in switch">,
- InGroup<SwitchEnum>;
+ InGroup<Switch>;
def warn_missing_case3 : Warning<
"enumeration values %0, %1, and %2 not handled in switch">,
- InGroup<SwitchEnum>;
+ InGroup<Switch>;
def warn_missing_cases : Warning<
"%0 enumeration values not handled in switch: %1, %2, %3...">,
- InGroup<SwitchEnum>;
+ InGroup<Switch>;
def warn_unreachable_default : Warning<
"default is unreachable as all enumeration values are accounted for">,
InGroup<SwitchEnumRedundantDefault>;
def warn_not_in_enum : Warning<"case value not in enumerated type %0">,
- InGroup<SwitchEnum>;
+ InGroup<Switch>;
def err_typecheck_statement_requires_scalar : Error<
"statement requires expression of scalar type (%0 invalid)">;
def err_typecheck_statement_requires_integer : Error<
Modified: cfe/trunk/test/SemaCXX/switch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/switch.cpp?rev=148648&r1=148647&r2=148648&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/switch.cpp (original)
+++ cfe/trunk/test/SemaCXX/switch.cpp Sat Jan 21 19:58:03 2012
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -Wswitch-enum %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
void test() {
bool x = true;
More information about the cfe-commits
mailing list