summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorLarisse Voufo <lvoufo@google.com>2015-02-10 02:20:14 +0000
committerLarisse Voufo <lvoufo@google.com>2015-02-10 02:20:14 +0000
commitbcf327af7b922955c1853666ea803b1e22420034 (patch)
tree793302743bead8b826fdd0b7de01a9a8177b32f8 /clang/lib/Sema/SemaInit.cpp
parent87661fb96386509a3c061cbe4ce05a5bc01ab5ea (diff)
downloadbcm5719-llvm-bcf327af7b922955c1853666ea803b1e22420034.tar.gz
bcm5719-llvm-bcf327af7b922955c1853666ea803b1e22420034.zip
A temporary fix for backward compatibility breakages caused by PR12117.
llvm-svn: 228654
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index b35110a1e28..a25aada0c2b 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -3113,7 +3113,7 @@ ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc,
ArrayRef<NamedDecl *> Ctors,
OverloadCandidateSet::iterator &Best,
bool CopyInitializing, bool AllowExplicit,
- bool OnlyListConstructors) {
+ bool OnlyListConstructors, bool IsListInit) {
CandidateSet.clear();
for (ArrayRef<NamedDecl *>::iterator
@@ -3138,7 +3138,16 @@ ResolveConstructorOverload(Sema &S, SourceLocation DeclLoc,
// of a class copy-initialization, or
// — 13.3.1.4, 13.3.1.5, or 13.3.1.6 (in all cases),
// user-defined conversion sequences are not considered.
- if (CopyInitializing && Constructor->isCopyOrMoveConstructor())
+ // FIXME: This breaks backward compatibility, e.g. PR12117. As a
+ // temporary fix, let's re-instate the third bullet above until
+ // there is a resolution in the standard, i.e.,
+ // - 13.3.1.7 when the initializer list has exactly one element that is
+ // itself an initializer list and a conversion to some class X or
+ // reference to (possibly cv-qualified) X is considered for the first
+ // parameter of a constructor of X.
+ if ((CopyInitializing ||
+ (IsListInit && Args.size() == 1 && isa<InitListExpr>(Args[0]))) &&
+ Constructor->isCopyOrMoveConstructor())
SuppressUserConversions = true;
}
@@ -3240,7 +3249,8 @@ static void TryConstructorInitialization(Sema &S,
Result = ResolveConstructorOverload(S, Kind.getLocation(), Args,
CandidateSet, Ctors, Best,
CopyInitialization, AllowExplicit,
- /*OnlyListConstructor=*/true);
+ /*OnlyListConstructor=*/true,
+ IsListInit);
// Time to unwrap the init list.
Args = MultiExprArg(ILE->getInits(), ILE->getNumInits());
@@ -3256,7 +3266,8 @@ static void TryConstructorInitialization(Sema &S,
Result = ResolveConstructorOverload(S, Kind.getLocation(), Args,
CandidateSet, Ctors, Best,
CopyInitialization, AllowExplicit,
- /*OnlyListConstructors=*/false);
+ /*OnlyListConstructors=*/false,
+ IsListInit);
}
if (Result) {
Sequence.SetOverloadFailure(IsListInit ?
OpenPOWER on IntegriCloud