r184650 - Fix assert if an attempt is made to explicitly instantiate an alias template.
Richard Smith
richard-llvm at metafoo.co.uk
Sat Jun 22 15:03:31 PDT 2013
Author: rsmith
Date: Sat Jun 22 17:03:31 2013
New Revision: 184650
URL: http://llvm.org/viewvc/llvm-project?rev=184650&view=rev
Log:
Fix assert if an attempt is made to explicitly instantiate an alias template.
Patch by Ismail Pazarbasi!
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/using-decl-templates.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=184650&r1=184649&r2=184650&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Sat Jun 22 17:03:31 2013
@@ -6341,14 +6341,22 @@ Sema::ActOnExplicitInstantiation(Scope *
AttributeList *Attr) {
// Find the class template we're specializing
TemplateName Name = TemplateD.getAsVal<TemplateName>();
- ClassTemplateDecl *ClassTemplate
- = cast<ClassTemplateDecl>(Name.getAsTemplateDecl());
-
+ TemplateDecl *TD = Name.getAsTemplateDecl();
// Check that the specialization uses the same tag kind as the
// original template.
TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForTypeSpec(TagSpec);
assert(Kind != TTK_Enum &&
"Invalid enum tag in class template explicit instantiation!");
+
+ if (isa<TypeAliasTemplateDecl>(TD)) {
+ Diag(KWLoc, diag::err_tag_reference_non_tag) << Kind;
+ Diag(TD->getTemplatedDecl()->getLocation(),
+ diag::note_previous_use);
+ return true;
+ }
+
+ ClassTemplateDecl *ClassTemplate = cast<ClassTemplateDecl>(TD);
+
if (!isAcceptableTagRedeclaration(ClassTemplate->getTemplatedDecl(),
Kind, /*isDefinition*/false, KWLoc,
*ClassTemplate->getIdentifier())) {
Modified: cfe/trunk/test/SemaCXX/using-decl-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/using-decl-templates.cpp?rev=184650&r1=184649&r2=184650&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/using-decl-templates.cpp (original)
+++ cfe/trunk/test/SemaCXX/using-decl-templates.cpp Sat Jun 22 17:03:31 2013
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s
template<typename T> struct A {
void f() { }
@@ -85,3 +85,10 @@ template<typename T> class UsingTypename
using typename T::X;
typename X::X x;
};
+
+namespace aliastemplateinst {
+ template<typename T> struct A { };
+ template<typename T> using APtr = A<T*>; // expected-note{{previous use is here}}
+
+ template struct APtr<int>; // expected-error{{elaborated type refers to a non-tag type}}
+}
More information about the cfe-commits
mailing list