Revert r88718, which does NOT solve the constructor-template-as-copy-constructor issue. Big thanks to John for finding this
llvm-svn: 88724
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 0e42bd6..47d2701 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -658,12 +658,6 @@
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 @@
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 @@
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 @@
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 @@
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,