From a25c4080a490ea2bab6f54094dd75b19eae83770 Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 19 Oct 2010 18:40:57 +0000 Subject: [PATCH] Tag references shouldn't ever get template parameter lists. Fixes rdar://problem/8568507 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116843 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Parse/ParseDeclCXX.cpp | 13 +++++++++---- test/SemaTemplate/elaborated-type-specifier.cpp | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/Parse/ParseDeclCXX.cpp b/lib/Parse/ParseDeclCXX.cpp index ce227c6ff2..083d6ab798 100644 --- a/lib/Parse/ParseDeclCXX.cpp +++ b/lib/Parse/ParseDeclCXX.cpp @@ -964,13 +964,18 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind, 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 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 diff --git a/test/SemaTemplate/elaborated-type-specifier.cpp b/test/SemaTemplate/elaborated-type-specifier.cpp index b34660acbe..514c5f2d57 100644 --- a/test/SemaTemplate/elaborated-type-specifier.cpp +++ b/test/SemaTemplate/elaborated-type-specifier.cpp @@ -34,3 +34,7 @@ namespace PR6649 { class T::bar { int x; }; // expected-error{{nested name specifier for a declaration cannot depend on a template parameter}} }; } + +namespace rdar8568507 { + template struct A *makeA(T t); +} -- 2.40.0