diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-11-14 01:20:54 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-11-14 01:20:54 +0000 |
commit | 66724ea67d7d598b937d86fa66f03f09a1c758f3 (patch) | |
tree | 5097599791ce784190a6cdf69e3f994114d6ade9 /lib/Sema/SemaOverload.cpp | |
parent | 0ff1042ddaad1419264be0de6da17f3b378482a4 (diff) |
If we attempt to add a constructor template specialization that looks
like a copy constructor to the overload set, just ignore it. This
ensures that we don't try to use such a constructor as a copy
constructor *without* triggering diagnostics at the point of
declaration.
Note that we *do* diagnose such copy constructors when explicitly
written by the user (e.g., as an explicit specialization).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88733 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 3948b22f7b..53e64dfc68 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -1422,7 +1422,7 @@ Sema::OverloadingResult Sema::IsUserDefinedConversion( = cast<CXXConstructorDecl>(ConstructorTmpl->getTemplatedDecl()); else Constructor = cast<CXXConstructorDecl>(*Con); - + if (!Constructor->isInvalidDecl() && Constructor->isConvertingConstructor(AllowExplicit)) { if (ConstructorTmpl) @@ -2239,7 +2239,18 @@ Sema::AddOverloadCandidate(FunctionDecl *Function, if (!CandidateSet.isNewCandidate(Function)) return; - + + if (CXXConstructorDecl *Constructor = dyn_cast<CXXConstructorDecl>(Function)){ + // 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. + QualType ClassType = Context.getTypeDeclType(Constructor->getParent()); + if (NumArgs == 1 && + Constructor->isCopyConstructorLikeSpecialization() && + Context.hasSameUnqualifiedType(ClassType, Args[0]->getType())) + return; + } + // Add this candidate CandidateSet.push_back(OverloadCandidate()); OverloadCandidate& Candidate = CandidateSet.back(); |