Look through sugar when determining whether a type is a scoped enumeration

type. Patch by Stephan Bergmann!

llvm-svn: 225889
This commit is contained in:
Richard Smith 2015-01-14 00:33:10 +00:00
parent a3b04cea04
commit 43d3f55072
2 changed files with 9 additions and 1 deletions

View File

@ -7546,7 +7546,7 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
}
static bool isScopedEnumerationType(QualType T) {
if (const EnumType *ET = dyn_cast<EnumType>(T))
if (const EnumType *ET = T->getAs<EnumType>())
return ET->getDecl()->isScoped();
return false;
}

View File

@ -301,3 +301,11 @@ namespace PR18044 {
using E::a; // ok!
E b = a;
}
namespace test11 {
enum class E { a };
typedef E E2;
E2 f1() { return E::a; }
bool f() { return !f1(); } // expected-error {{invalid argument type 'E2' (aka 'test11::E') to unary expression}}
}