diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-11-13 23:59:09 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-11-13 23:59:09 +0000 |
commit | fd47648b5d351ff6d1a3e886e1c3d10712ba4675 (patch) | |
tree | e87bd20c38f9553a171e0db9dc008ab8ce4b2f65 /lib/Sema/SemaTemplateInstantiateDecl.cpp | |
parent | e99cc4504946718e4f288f6ba4652c3c7ffa6996 (diff) |
Revert r88718, which does NOT solve the constructor-template-as-copy-constructor issue. Big thanks to John for finding this
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88724 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplateInstantiateDecl.cpp')
-rw-r--r-- | lib/Sema/SemaTemplateInstantiateDecl.cpp | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/lib/Sema/SemaTemplateInstantiateDecl.cpp b/lib/Sema/SemaTemplateInstantiateDecl.cpp index 0e42bd65db..47d2701bcd 100644 --- a/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -658,12 +658,6 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) { TemplateParams, Function); Function->setDescribedFunctionTemplate(FunctionTemplate); FunctionTemplate->setLexicalDeclContext(D->getLexicalDeclContext()); - } else if (FunctionTemplate) { - // Record this function template specialization. - Function->setFunctionTemplateSpecialization(SemaRef.Context, - FunctionTemplate, - &TemplateArgs.getInnermost(), - InsertPos); } if (InitFunctionInstantiation(Function, D)) @@ -715,6 +709,14 @@ Decl *TemplateDeclInstantiator::VisitCXXRecordDecl(CXXRecordDecl *D) { Function->setInstantiationOfMemberFunction(D, TSK_ImplicitInstantiation); } + if (FunctionTemplate && !TemplateParams) { + // Record this function template specialization. + Function->setFunctionTemplateSpecialization(SemaRef.Context, + FunctionTemplate, + &TemplateArgs.getInnermost(), + InsertPos); + } + return Function; } @@ -809,17 +811,9 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, if (D->isOutOfLine()) FunctionTemplate->setLexicalDeclContext(D->getLexicalDeclContext()); Method->setDescribedFunctionTemplate(FunctionTemplate); - } else if (FunctionTemplate) { - // Record this function template specialization. - Method->setFunctionTemplateSpecialization(SemaRef.Context, - FunctionTemplate, - &TemplateArgs.getInnermost(), - InsertPos); - } else { - // Record this instantiation of a member function. + } else if (!FunctionTemplate) Method->setInstantiationOfMemberFunction(D, TSK_ImplicitInstantiation); - } - + // If we are instantiating a member function defined // out-of-line, the instantiation will have the same lexical // context (which will be a namespace scope) as the template. @@ -831,20 +825,6 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, Params[P]->setOwningFunction(Method); Method->setParams(SemaRef.Context, Params.data(), Params.size()); - if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(Method)) { - // C++ [class.copy]p3: - // [...] A member function template is never instantiated to perform the - // copy of a class object to an object of its class type. - if (FunctionTemplate && !TemplateParams && - Constructor->isCopyConstructor(SemaRef.Context)) { - SemaRef.Diag(Constructor->getLocation(), - diag::err_constructor_template_is_copy_constructor) - << Constructor; - Method->setInvalidDecl(); - return Method; - } - } - if (InitMethodInstantiation(Method, D)) Method->setInvalidDecl(); @@ -863,6 +843,13 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D, PrevDecl = 0; } + if (FunctionTemplate && !TemplateParams) + // Record this function template specialization. + Method->setFunctionTemplateSpecialization(SemaRef.Context, + FunctionTemplate, + &TemplateArgs.getInnermost(), + InsertPos); + bool Redeclaration = false; bool OverloadableAttrRequired = false; SemaRef.CheckFunctionDeclaration(Method, PrevDecl, false, Redeclaration, |