diff options
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticGroups.td | 2 | ||||
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticSemaKinds.td | 6 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaStmt.cpp | 2 | ||||
| -rw-r--r-- | clang/test/Sema/switch.c | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/warn-enum-compare.cpp | 6 |
5 files changed, 12 insertions, 6 deletions
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td b/clang/include/clang/Basic/DiagnosticGroups.td index 1b102ba7269..be800d26c86 100644 --- a/clang/include/clang/Basic/DiagnosticGroups.td +++ b/clang/include/clang/Basic/DiagnosticGroups.td @@ -454,6 +454,8 @@ def CoveredSwitchDefault : DiagGroup<"covered-switch-default">; def SwitchBool : DiagGroup<"switch-bool">; def SwitchEnum : DiagGroup<"switch-enum">; def Switch : DiagGroup<"switch">; +def EnumCompareSwitch : DiagGroup<"enum-compare-switch">; +def EnumCompare : DiagGroup<"enum-compare", [EnumCompareSwitch]>; def ImplicitFallthroughPerFunction : DiagGroup<"implicit-fallthrough-per-function">; def ImplicitFallthrough : DiagGroup<"implicit-fallthrough", diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index b251bd1967a..8dfd0eb89a0 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -5918,7 +5918,11 @@ def warn_runsigned_always_true_comparison : Warning< def warn_comparison_of_mixed_enum_types : Warning< "comparison of two values with different enumeration types" "%diff{ ($ and $)|}0,1">, - InGroup<DiagGroup<"enum-compare">>; + InGroup<EnumCompare>; +def warn_comparison_of_mixed_enum_types_switch : Warning< + "comparison of two values with different enumeration types in switch statement" + "%diff{ ($ and $)|}0,1">, + InGroup<EnumCompareSwitch>; def warn_null_in_arithmetic_operation : Warning< "use of NULL in arithmetic operation">, InGroup<NullArithmetic>; diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 1b6aed61933..2e1ea3e2f64 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -762,7 +762,7 @@ static void checkEnumTypesInSwitchStmt(Sema &S, const Expr *Cond, if (S.Context.hasSameUnqualifiedType(CondType, CaseType)) return; - S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types) + S.Diag(Case->getExprLoc(), diag::warn_comparison_of_mixed_enum_types_switch) << CondType << CaseType << Cond->getSourceRange() << Case->getSourceRange(); } diff --git a/clang/test/Sema/switch.c b/clang/test/Sema/switch.c index e4e4ee5497a..a33300b41f5 100644 --- a/clang/test/Sema/switch.c +++ b/clang/test/Sema/switch.c @@ -372,7 +372,7 @@ void switch_on_ExtendedEnum1(enum ExtendedEnum1 e) { case EE1_b: break; case EE1_c: break; // no-warning case EE1_d: break; // expected-warning {{case value not in enumerated type 'enum ExtendedEnum1'}} - // expected-warning@-1 {{comparison of two values with different enumeration types ('enum ExtendedEnum1' and 'const enum ExtendedEnum1_unrelated')}} + // expected-warning@-1 {{comparison of two values with different enumeration types in switch statement ('enum ExtendedEnum1' and 'const enum ExtendedEnum1_unrelated')}} } } diff --git a/clang/test/SemaCXX/warn-enum-compare.cpp b/clang/test/SemaCXX/warn-enum-compare.cpp index f82f7750be8..0d7558dba7d 100644 --- a/clang/test/SemaCXX/warn-enum-compare.cpp +++ b/clang/test/SemaCXX/warn-enum-compare.cpp @@ -212,19 +212,19 @@ void test () { switch (a) { case name1::F1: break; case name1::F3: break; - case name2::B2: break; // expected-warning {{comparison of two values with different enumeration types ('name1::Foo' and 'name2::Baz')}} + case name2::B2: break; // expected-warning {{comparison of two values with different enumeration types in switch statement ('name1::Foo' and 'name2::Baz')}} } switch (x) { case FooB: break; case FooC: break; - case BarD: break; // expected-warning {{comparison of two values with different enumeration types ('Foo' and 'Bar')}} + case BarD: break; // expected-warning {{comparison of two values with different enumeration types in switch statement ('Foo' and 'Bar')}} } switch(getBar()) { case BarE: break; case BarF: break; - case FooA: break; // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}} + case FooA: break; // expected-warning {{comparison of two values with different enumeration types in switch statement ('Bar' and 'Foo')}} } switch(x) { |

