From 8f003d0fa361cf2236764c724a2009329737e5da Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 15 Oct 2009 18:07:02 +0000 Subject: Make sure that we're diagnosing duplicate explicit instantiation definitions. llvm-svn: 84189 --- clang/lib/Sema/SemaTemplate.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'clang/lib/Sema/SemaTemplate.cpp') diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 8d7e199e7a8..730fea30b5a 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -3818,8 +3818,11 @@ Sema::ActOnExplicitInstantiation(Scope *S, CheckExplicitInstantiationScope(*this, Record, NameLoc, true); // Verify that it is okay to explicitly instantiate here. - if (CXXRecordDecl *PrevDecl - = cast_or_null(Record->getPreviousDeclaration())) { + CXXRecordDecl *PrevDecl + = cast_or_null(Record->getPreviousDeclaration()); + if (!PrevDecl && Record->getDefinition(Context)) + PrevDecl = Record; + if (PrevDecl) { MemberSpecializationInfo *MSInfo = PrevDecl->getMemberSpecializationInfo(); bool SuppressNew = false; assert(MSInfo && "No member specialization information?"); @@ -4065,6 +4068,9 @@ Sema::DeclResult Sema::ActOnExplicitInstantiation(Scope *S, } FunctionDecl *PrevDecl = Specialization->getPreviousDeclaration(); + if (!PrevDecl && Specialization->isThisDeclarationADefinition()) + PrevDecl = Specialization; + if (PrevDecl) { bool SuppressNew = false; if (CheckSpecializationInstantiationRedecl(*this, D.getIdentifierLoc(), TSK, -- cgit v1.2.3