Fix assert if an attempt is made to explicitly instantiate an alias template.

Patch by Ismail Pazarbasi!

llvm-svn: 184650
This commit is contained in:
Richard Smith 2013-06-22 22:03:31 +00:00
parent 829c6e6f41
commit 392497bebe
2 changed files with 19 additions and 4 deletions

View File

@ -6341,14 +6341,22 @@ Sema::ActOnExplicitInstantiation(Scope *S,
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())) {

View File

@ -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 UsingTypenameNNS {
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}}
}