r228654 - A temporary fix for backward compatibility breakages caused by PR12117.
Larisse Voufo
lvoufo at google.com
Mon Feb 9 18:20:14 PST 2015
Author: lvoufo
Date: Mon Feb 9 20:20:14 2015
New Revision: 228654
URL: http://llvm.org/viewvc/llvm-project?rev=228654&view=rev
Log:
A temporary fix for backward compatibility breakages caused by PR12117.
Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp
Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=228654&r1=228653&r2=228654&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Mon Feb 9 20:20:14 2015
@@ -3113,7 +3113,7 @@ ResolveConstructorOverload(Sema &S, Sour
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, Sour
// 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
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
Result = ResolveConstructorOverload(S, Kind.getLocation(), Args,
CandidateSet, Ctors, Best,
CopyInitialization, AllowExplicit,
- /*OnlyListConstructors=*/false);
+ /*OnlyListConstructors=*/false,
+ IsListInit);
}
if (Result) {
Sequence.SetOverloadFailure(IsListInit ?
Modified: cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp?rev=228654&r1=228653&r2=228654&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-initializer-constructor.cpp Mon Feb 9 20:20:14 2015
@@ -214,9 +214,10 @@ namespace PR12092 {
namespace PR12117 {
struct A { A(int); };
- struct B { B(A); } b{{0}}; // expected-error {{call to constructor of 'struct B' is ambiguous}} \
- // expected-note 2{{candidate is the implicit}} \
- // expected-note {{candidate constructor}}
+ struct B { B(A); } b{{0}}; //FIXME: non-conformant. Temporary fix until standard resolution.
+ // expected- error {{call to constructor of 'struct B' is ambiguous}} \
+ // expected- note 2{{candidate is the implicit}} \
+ // expected- note {{candidate constructor}}
struct C { C(int); } c{0};
}
More information about the cfe-commits
mailing list