Properly handle non-canonical underlying types in

ASTContext::getUnaryTransformType.  This can happen if, for example,
an enumeration's underlying type is a typedef.

llvm-svn: 152031
This commit is contained in:
Peter Collingbourne 2012-03-05 16:02:06 +00:00
parent b3ec7308b0
commit 15d48ec46f
2 changed files with 7 additions and 1 deletions

View File

@ -2962,7 +2962,7 @@ QualType ASTContext::getUnaryTransformType(QualType BaseType,
new (*this, TypeAlignment) UnaryTransformType (BaseType, UnderlyingType,
Kind,
UnderlyingType->isDependentType() ?
QualType() : UnderlyingType);
QualType() : getCanonicalType(UnderlyingType));
Types.push_back(Ty);
return QualType(Ty, 0);
}

View File

@ -35,3 +35,9 @@ static_assert(is_same_type<underlying_type<f>::type, char>::value,
"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");