[cfe-commits] r116843 - in /cfe/trunk: lib/Parse/ParseDeclCXX.cpp test/SemaTemplate/elaborated-type-specifier.cpp

John McCall rjmccall at apple.com
Tue Oct 19 11:40:57 PDT 2010


Author: rjmccall
Date: Tue Oct 19 13:40:57 2010
New Revision: 116843

URL: http://llvm.org/viewvc/llvm-project?rev=116843&view=rev
Log:
Tag references shouldn't ever get template parameter lists.
Fixes rdar://problem/8568507


Modified:
    cfe/trunk/lib/Parse/ParseDeclCXX.cpp
    cfe/trunk/test/SemaTemplate/elaborated-type-specifier.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=116843&r1=116842&r2=116843&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Tue Oct 19 13:40:57 2010
@@ -964,13 +964,18 @@
 
     bool IsDependent = false;
 
+    // Don't pass down template parameter lists if this is just a tag
+    // reference.  For example, we don't need the template parameters here:
+    //   template <class T> class A *makeA(T t);
+    MultiTemplateParamsArg TParams;
+    if (TUK != Sema::TUK_Reference && TemplateParams)
+      TParams =
+        MultiTemplateParamsArg(&(*TemplateParams)[0], TemplateParams->size());
+
     // Declaration or definition of a class type
     TagOrTempResult = Actions.ActOnTag(getCurScope(), TagType, TUK, StartLoc,
                                        SS, Name, NameLoc, AttrList, AS,
-                                       MultiTemplateParamsArg(Actions,
-                                    TemplateParams? &(*TemplateParams)[0] : 0,
-                                    TemplateParams? TemplateParams->size() : 0),
-                                       Owned, IsDependent, false,
+                                       TParams, Owned, IsDependent, false,
                                        clang::TypeResult());
 
     // If ActOnTag said the type was dependent, try again with the

Modified: cfe/trunk/test/SemaTemplate/elaborated-type-specifier.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/elaborated-type-specifier.cpp?rev=116843&r1=116842&r2=116843&view=diff
==============================================================================
--- cfe/trunk/test/SemaTemplate/elaborated-type-specifier.cpp (original)
+++ cfe/trunk/test/SemaTemplate/elaborated-type-specifier.cpp Tue Oct 19 13:40:57 2010
@@ -34,3 +34,7 @@
     class T::bar { int x; }; // expected-error{{nested name specifier for a declaration cannot depend on a template parameter}}
   };
 }
+
+namespace rdar8568507 {
+  template <class T> struct A *makeA(T t);
+}





More information about the cfe-commits mailing list