]> granicus.if.org Git - clang/commitdiff
Correctly skip type sugar when determining the width of an enum type. Derived
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 15 Oct 2013 04:56:17 +0000 (04:56 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 15 Oct 2013 04:56:17 +0000 (04:56 +0000)
from a patch by Justin Bogner.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192671 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/SemaCXX/enum-scoped.cpp

index 04711e330c081144e5450820d6536ebe3798e75e..1774b804f1fbe6217166836a04813fa2afbba6bd 100644 (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;
index a9a6de9592edfdf433246a3ced8ac89bb7914fb4..c6869449caa151ca36928f8107ebfadf3fbbbabc 100644 (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, "");
+}
+