From adabbca569bd6c6dfe91773dea8cf7d14cb4cc5e Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sun, 22 Jan 2012 01:58:03 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148648 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticGroups.td | 4 ++-- include/clang/Basic/DiagnosticSemaKinds.td | 10 +++++----- test/SemaCXX/switch.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/clang/Basic/DiagnosticGroups.td b/include/clang/Basic/DiagnosticGroups.td index ca0ce99c2c..7211db2984 100644 --- a/include/clang/Basic/DiagnosticGroups.td +++ b/include/clang/Basic/DiagnosticGroups.td @@ -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">; diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 3ffd580b83..b4f61ce1ca 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -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; + InGroup; def warn_missing_case2 : Warning< "enumeration values %0 and %1 not handled in switch">, - InGroup; + InGroup; def warn_missing_case3 : Warning< "enumeration values %0, %1, and %2 not handled in switch">, - InGroup; + InGroup; def warn_missing_cases : Warning< "%0 enumeration values not handled in switch: %1, %2, %3...">, - InGroup; + InGroup; def warn_unreachable_default : Warning< "default is unreachable as all enumeration values are accounted for">, InGroup; def warn_not_in_enum : Warning<"case value not in enumerated type %0">, - InGroup; + InGroup; def err_typecheck_statement_requires_scalar : Error< "statement requires expression of scalar type (%0 invalid)">; def err_typecheck_statement_requires_integer : Error< diff --git a/test/SemaCXX/switch.cpp b/test/SemaCXX/switch.cpp index 8a8cf33049..5fd6b1a6e1 100644 --- a/test/SemaCXX/switch.cpp +++ b/test/SemaCXX/switch.cpp @@ -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; -- 2.40.0