Correctly skip type sugar when determining the width of an enum type. Derived

from a patch by Justin Bogner.

llvm-svn: 192671
This commit is contained in:
Richard Smith 2013-10-15 04:56:17 +00:00
parent 84342d69b0
commit e952106164
2 changed files with 12 additions and 1 deletions

View File

@ -7478,7 +7478,7 @@ QualType ASTContext::mergeObjCGCQualifiers(QualType LHS, QualType RHS) {
//===----------------------------------------------------------------------===//
unsigned ASTContext::getIntWidth(QualType T) const {
if (const EnumType *ET = dyn_cast<EnumType>(T))
if (const EnumType *ET = T->getAs<EnumType>())
T = ET->getDecl()->getIntegerType();
if (T->isBooleanType())
return 1;

View File

@ -271,3 +271,14 @@ namespace PR16900 {
enum class A;
A f(A a) { return -a; } // expected-error {{invalid argument type 'PR16900::A' to unary expression}}
}
namespace rdar15124329 {
enum class B : bool { F, T };
const rdar15124329::B T1 = B::T;
typedef B C; const C T2 = B::T;
static_assert(T1 != B::F, "");
static_assert(T2 == B::T, "");
}