aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-11-12 03:34:06 +0000
committerDouglas Gregor <dgregor@apple.com>2010-11-12 03:34:06 +0000
commit8ff338bfd8abd9ac5d0c1d89c1b05e2c02727174 (patch)
treefb31fec40321d2a3b7a2f0366e97f47ee40178db /lib/Sema/SemaInit.cpp
parent89414b384a0004c698244cc675f49d0669bb3463 (diff)
When performing initialization of a copy of a temporary object, use
direct-initialization (rather than copy-initialization) to initialize the temporary, allowing explicit constructors. Fixes PR8342. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118880 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r--lib/Sema/SemaInit.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index ffbb76d8c5..7025369b85 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -3391,14 +3391,16 @@ static ExprResult CopyObject(Sema &S,
OverloadCandidateSet CandidateSet(Loc);
for (llvm::tie(Con, ConEnd) = S.LookupConstructors(Class);
Con != ConEnd; ++Con) {
- // Only consider copy constructors and constructor templates.
+ // Only consider copy constructors and constructor templates. Per
+ // C++0x [dcl.init]p16, second bullet to class types, this
+ // initialization is direct-initialization.
CXXConstructorDecl *Constructor = 0;
if ((Constructor = dyn_cast<CXXConstructorDecl>(*Con))) {
// Handle copy constructors, only.
if (!Constructor || Constructor->isInvalidDecl() ||
!Constructor->isCopyConstructor() ||
- !Constructor->isConvertingConstructor(/*AllowExplicit=*/false))
+ !Constructor->isConvertingConstructor(/*AllowExplicit=*/true))
continue;
DeclAccessPair FoundDecl
@@ -3415,7 +3417,7 @@ static ExprResult CopyObject(Sema &S,
Constructor = cast<CXXConstructorDecl>(
ConstructorTmpl->getTemplatedDecl());
- if (!Constructor->isConvertingConstructor(/*AllowExplicit=*/false))
+ if (!Constructor->isConvertingConstructor(/*AllowExplicit=*/true))
continue;
// FIXME: Do we need to limit this to copy-constructor-like