[cfe-commits] r71878 - in /cfe/trunk: include/clang/AST/DeclCXX.h lib/AST/DeclCXX.cpp lib/Sema/SemaTemplate.cpp

Douglas Gregor dgregor at apple.com
Fri May 15 12:11:46 PDT 2009


Author: dgregor
Date: Fri May 15 14:11:46 2009
New Revision: 71878

URL: http://llvm.org/viewvc/llvm-project?rev=71878&view=rev
Log:
Make sure that the type associated with a class template is dependent.

Modified:
    cfe/trunk/include/clang/AST/DeclCXX.h
    cfe/trunk/lib/AST/DeclCXX.cpp
    cfe/trunk/lib/Sema/SemaTemplate.cpp

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=71878&r1=71877&r2=71878&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Fri May 15 14:11:46 2009
@@ -264,7 +264,8 @@
 
   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);

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=71878&r1=71877&r2=71878&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Fri May 15 14:11:46 2009
@@ -35,9 +35,11 @@
 
 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;
 }
 

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=71878&r1=71877&r2=71878&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri May 15 14:11:46 2009
@@ -509,7 +509,8 @@
   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 @@
                                 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);
   





More information about the cfe-commits mailing list