From: Richard Smith Date: Tue, 15 Oct 2013 04:56:17 +0000 (+0000) Subject: Correctly skip type sugar when determining the width of an enum type. Derived X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b7f23f18acaf84d14d6ca2c02c12c22e68d72837;p=clang Correctly skip type sugar when determining the width of an enum type. Derived from a patch by Justin Bogner. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192671 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 04711e330c..1774b804f1 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -7478,7 +7478,7 @@ QualType ASTContext::mergeObjCGCQualifiers(QualType LHS, QualType RHS) { //===----------------------------------------------------------------------===// unsigned ASTContext::getIntWidth(QualType T) const { - if (const EnumType *ET = dyn_cast(T)) + if (const EnumType *ET = T->getAs()) T = ET->getDecl()->getIntegerType(); if (T->isBooleanType()) return 1; diff --git a/test/SemaCXX/enum-scoped.cpp b/test/SemaCXX/enum-scoped.cpp index a9a6de9592..c6869449ca 100644 --- a/test/SemaCXX/enum-scoped.cpp +++ b/test/SemaCXX/enum-scoped.cpp @@ -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, ""); +} +