[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:
Gabor Horvath 2017-08-09 12:34:58 +00:00
parent 3bfb365f52
commit b57e264257
2 changed files with 13 additions and 0 deletions

View File

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

View File

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