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.

llvm-svn: 148648
This commit is contained in:
David Blaikie 2012-01-22 01:58:03 +00:00
parent 1a56ee3798
commit 29e7d60880
3 changed files with 8 additions and 8 deletions

View File

@ -178,9 +178,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 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">;

View File

@ -4946,22 +4946,22 @@ def warn_case_empty_range : Warning<"empty case range specified">;
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<

View File

@ -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;