]> granicus.if.org Git - clang/commitdiff
PR18400: ignore cv-qualifiers on the underlying type of an enumeration.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 8 Jan 2014 01:16:19 +0000 (01:16 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Wed, 8 Jan 2014 01:16:19 +0000 (01:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198723 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
lib/Sema/SemaDecl.cpp
test/CXX/dcl.dcl/dcl.enum/p2.cpp [new file with mode: 0644]

index 09aff1b39790eb57542dc8bb3d7610e209bc663f..5913a83699c98d37a0e45ed908a0945338457058 100644 (file)
@@ -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 TypeT = 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(TypeSourceInfoTInfo) { 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.
-  TypeSourceInfogetIntegerTypeSourceInfo() const {
+  TypeSourceInfo *getIntegerTypeSourceInfo() const {
     return IntegerType.dyn_cast<TypeSourceInfo*>();
   }
 
index 7cdf81a87e403aeb8f91a0e610044d680266daad..fb041ed98c85470f2eb10807d7eca3aa004f0eec 100644 (file)
@@ -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/test/CXX/dcl.dcl/dcl.enum/p2.cpp b/test/CXX/dcl.dcl/dcl.enum/p2.cpp
new file mode 100644 (file)
index 0000000..de826d0
--- /dev/null
@@ -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;