forked from OSchip/llvm-project
[Sema] -Wenum-compare no longer warn on anonymous enums in switch statements
Patch by: Reka Nikolett Kovacs llvm-svn: 310468
This commit is contained in:
parent
3bfb365f52
commit
b57e264257
|
@ -753,6 +753,12 @@ static void checkEnumTypesInSwitchStmt(Sema &S, const Expr *Cond,
|
|||
if (!CondEnumType || !CaseEnumType)
|
||||
return;
|
||||
|
||||
// Ignore anonymous enums.
|
||||
if (!CondEnumType->getDecl()->getIdentifier())
|
||||
return;
|
||||
if (!CaseEnumType->getDecl()->getIdentifier())
|
||||
return;
|
||||
|
||||
if (S.Context.hasSameUnqualifiedType(CondType, CaseType))
|
||||
return;
|
||||
|
||||
|
|
|
@ -226,4 +226,11 @@ void test () {
|
|||
case BarF: break;
|
||||
case FooA: break; // expected-warning {{comparison of two values with different enumeration types ('Bar' and 'Foo')}}
|
||||
}
|
||||
|
||||
switch(x) {
|
||||
case AnonAA: break; // expected-warning {{case value not in enumerated type 'Foo'}}
|
||||
case FooA: break;
|
||||
case FooB: break;
|
||||
case FooC: break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue