]> granicus.if.org Git - clang/commitdiff
Make sure that the type associated with a class template is dependent.
authorDouglas Gregor <dgregor@apple.com>
Fri, 15 May 2009 19:11:46 +0000 (19:11 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 15 May 2009 19:11:46 +0000 (19:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71878 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclCXX.h
lib/AST/DeclCXX.cpp
lib/Sema/SemaTemplate.cpp

index 88d6f9fa2b8e456014210c96fc0479d94f1f5486..28a6f2d36748e78045c61d2f3fd37893e7e98caf 100644 (file)
@@ -264,7 +264,8 @@ public:
 
   static CXXRecordDecl *Create(ASTContext &C, TagKind TK, DeclContext *DC,
                                SourceLocation L, IdentifierInfo *Id,
-                               CXXRecordDecl* PrevDecl=0);
+                               CXXRecordDecl* PrevDecl=0,
+                               bool DelayTypeCreation = false);
   
   /// setBases - Sets the base classes of this struct or class.
   void setBases(CXXBaseSpecifier const * const *Bases, unsigned NumBases);
index c32aefb830b1656c742e34508a4d0f118e66df42..361fef0325d09678e6c6b1a4e103bf8715734839 100644 (file)
@@ -35,9 +35,11 @@ CXXRecordDecl::CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC,
 
 CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
                                      SourceLocation L, IdentifierInfo *Id,
-                                     CXXRecordDecl* PrevDecl) {
+                                     CXXRecordDecl* PrevDecl,
+                                     bool DelayTypeCreation) {
   CXXRecordDecl* R = new (C) CXXRecordDecl(CXXRecord, TK, DC, L, Id);
-  C.getTypeDeclType(R, PrevDecl);  
+  if (!DelayTypeCreation)
+    C.getTypeDeclType(R, PrevDecl);  
   return R;
 }
 
index 09e32f7b65c5e0cd97742f14556a93472f76e228..afd801cf619df1bf9b778b706a2da6eeaa9ad354 100644 (file)
@@ -509,7 +509,8 @@ Sema::ActOnClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
   CXXRecordDecl *NewClass = 
     CXXRecordDecl::Create(Context, Kind, SemanticContext, NameLoc, Name,
                           PrevClassTemplate? 
-                            PrevClassTemplate->getTemplatedDecl() : 0);
+                            PrevClassTemplate->getTemplatedDecl() : 0,
+                          /*DelayTypeCreation=*/true);
 
   ClassTemplateDecl *NewTemplate
     = ClassTemplateDecl::Create(Context, SemanticContext, NameLoc,
@@ -517,6 +518,14 @@ Sema::ActOnClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
                                 NewClass, PrevClassTemplate);
   NewClass->setDescribedClassTemplate(NewTemplate);
 
+  // Build the type for the class template declaration now.
+  QualType T = 
+    Context.getTypeDeclType(NewClass, 
+                            PrevClassTemplate? 
+                              PrevClassTemplate->getTemplatedDecl() : 0);  
+  assert(T->isDependentType() && "Class template type is not dependent?");
+  (void)T;
+
   // Set the access specifier.
   SetMemberAccessSpecifier(NewTemplate, PrevClassTemplate, AS);