[cfe-commits] r152031 - in /cfe/trunk: lib/AST/ASTContext.cpp test/SemaCXX/underlying_type.cpp

Peter Collingbourne peter at pcc.me.uk
Mon Mar 5 08:02:07 PST 2012


Author: pcc
Date: Mon Mar  5 10:02:06 2012
New Revision: 152031

URL: http://llvm.org/viewvc/llvm-project?rev=152031&view=rev
Log:
Properly handle non-canonical underlying types in
ASTContext::getUnaryTransformType.  This can happen if, for example,
an enumeration's underlying type is a typedef.

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/SemaCXX/underlying_type.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=152031&r1=152030&r2=152031&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Mar  5 10:02:06 2012
@@ -2962,7 +2962,7 @@
     new (*this, TypeAlignment) UnaryTransformType (BaseType, UnderlyingType, 
                                                    Kind,
                                  UnderlyingType->isDependentType() ?
-                                    QualType() : UnderlyingType);
+                                 QualType() : getCanonicalType(UnderlyingType));
   Types.push_back(Ty);
   return QualType(Ty, 0);
 }

Modified: cfe/trunk/test/SemaCXX/underlying_type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/underlying_type.cpp?rev=152031&r1=152030&r2=152031&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/underlying_type.cpp (original)
+++ cfe/trunk/test/SemaCXX/underlying_type.cpp Mon Mar  5 10:02:06 2012
@@ -35,3 +35,9 @@
               "f has the wrong underlying type in the template");
 
 underlying_type<int>::type e; // expected-note {{requested here}}
+
+using uint = unsigned;
+enum class foo : uint { bar };
+ 
+static_assert(is_same_type<underlying_type<foo>::type, unsigned>::value,
+              "foo has the wrong underlying type");





More information about the cfe-commits mailing list