aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-10-13 23:45:19 +0000
committerDouglas Gregor <dgregor@apple.com>2009-10-13 23:45:19 +0000
commit77da3f4815069dbd029823edb072425551143cb1 (patch)
tree0f226a1e30b659903769d20d9cc3f971d2dc188d
parenta786fdbf6c1d8ff08c3e61c7eb6bf2872895e2b4 (diff)
Member function templates (and instantiations/specializations thereof)
are never copy constructors or copy assignment operators. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84057 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/DeclCXX.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index b9a87aedd7..457f4c85a0 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -192,7 +192,8 @@ bool CXXRecordDecl::hasConstCopyAssignment(ASTContext &Context,
const CXXMethodDecl* Method = cast<CXXMethodDecl>(*Op);
if (Method->isStatic())
continue;
- // TODO: Skip templates? Or is this implicitly done due to parameter types?
+ if (Method->getPrimaryTemplate())
+ continue;
const FunctionProtoType *FnType =
Method->getType()->getAs<FunctionProtoType>();
assert(FnType && "Overloaded operator has no prototype.");
@@ -259,6 +260,11 @@ void CXXRecordDecl::addedAssignmentOperator(ASTContext &Context,
const FunctionProtoType *FnType = OpDecl->getType()->getAs<FunctionProtoType>();
assert(FnType && "Overloaded operator has no proto function type.");
assert(FnType->getNumArgs() == 1 && !FnType->isVariadic());
+
+ // Copy assignment operators must be non-templates.
+ if (OpDecl->getPrimaryTemplate() || OpDecl->getDescribedFunctionTemplate())
+ return;
+
QualType ArgType = FnType->getArgType(0);
if (const LValueReferenceType *Ref = ArgType->getAs<LValueReferenceType>())
ArgType = Ref->getPointeeType();
@@ -694,7 +700,9 @@ CXXConstructorDecl::isCopyConstructor(ASTContext &Context,
// const volatile X&, and either there are no other parameters
// or else all other parameters have default arguments (8.3.6).
if ((getNumParams() < 1) ||
- (getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()))
+ (getNumParams() > 1 && !getParamDecl(1)->hasDefaultArg()) ||
+ (getPrimaryTemplate() != 0) ||
+ (getDescribedFunctionTemplate() != 0))
return false;
const ParmVarDecl *Param = getParamDecl(0);