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

Richard Smith richard-llvm at metafoo.co.uk
Mon Oct 14 21:56:17 PDT 2013


Author: rsmith
Date: Mon Oct 14 23:56:17 2013
New Revision: 192671

URL: http://llvm.org/viewvc/llvm-project?rev=192671&view=rev
Log:
Correctly skip type sugar when determining the width of an enum type. Derived
from a patch by Justin Bogner.

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/SemaCXX/enum-scoped.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=192671&r1=192670&r2=192671&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Oct 14 23:56:17 2013
@@ -7478,7 +7478,7 @@ QualType ASTContext::mergeObjCGCQualifie
 //===----------------------------------------------------------------------===//
 
 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;

Modified: cfe/trunk/test/SemaCXX/enum-scoped.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/enum-scoped.cpp?rev=192671&r1=192670&r2=192671&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/enum-scoped.cpp (original)
+++ cfe/trunk/test/SemaCXX/enum-scoped.cpp Mon Oct 14 23:56:17 2013
@@ -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, "");
+}
+





More information about the cfe-commits mailing list