diff options
-rw-r--r-- | clang/include/clang/AST/Decl.h | 11 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | clang/test/CXX/dcl.dcl/dcl.enum/p2.cpp | 6 |
3 files changed, 13 insertions, 6 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 09aff1b3979..5913a83699c 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -2879,24 +2879,25 @@ public: void setPromotionType(QualType T) { PromotionType = T; } /// getIntegerType - Return the integer type this enum decl corresponds to. - /// This returns a null qualtype for an enum forward definition. + /// This returns a null QualType for an enum forward definition with no fixed + /// underlying type. QualType getIntegerType() const { if (!IntegerType) return QualType(); - if (const Type* T = IntegerType.dyn_cast<const Type*>()) + if (const Type *T = IntegerType.dyn_cast<const Type*>()) return QualType(T, 0); - return IntegerType.get<TypeSourceInfo*>()->getType(); + return IntegerType.get<TypeSourceInfo*>()->getType().getUnqualifiedType(); } /// \brief Set the underlying integer type. void setIntegerType(QualType T) { IntegerType = T.getTypePtrOrNull(); } /// \brief Set the underlying integer type source info. - void setIntegerTypeSourceInfo(TypeSourceInfo* TInfo) { IntegerType = TInfo; } + void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo) { IntegerType = TInfo; } /// \brief Return the type source info for the underlying integer type, /// if no type source info exists, return 0. - TypeSourceInfo* getIntegerTypeSourceInfo() const { + TypeSourceInfo *getIntegerTypeSourceInfo() const { return IntegerType.dyn_cast<TypeSourceInfo*>(); } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 7cdf81a87e4..fb041ed98c8 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -10785,7 +10785,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, QualType EnumUnderlyingTy; if (TypeSourceInfo *TI = EnumUnderlying.dyn_cast<TypeSourceInfo*>()) - EnumUnderlyingTy = TI->getType(); + EnumUnderlyingTy = TI->getType().getUnqualifiedType(); else if (const Type *T = EnumUnderlying.dyn_cast<const Type*>()) EnumUnderlyingTy = QualType(T, 0); diff --git a/clang/test/CXX/dcl.dcl/dcl.enum/p2.cpp b/clang/test/CXX/dcl.dcl/dcl.enum/p2.cpp new file mode 100644 index 00000000000..de826d05704 --- /dev/null +++ b/clang/test/CXX/dcl.dcl/dcl.enum/p2.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -std=c++11 -verify %s + +// expected-no-diagnostics +enum class E : int const volatile { }; +using T = __underlying_type(E); +using T = int; |