When creating an implicit conversion sequence for a reference of type T from an
initializer list containing a single element of type T, be sure to mark the
sequence as a list conversion sequence so that it is known to be worse than an
implicit conversion sequence that initializes a std::initializer_list object.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190115 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index a8b0bd2..54b0547 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -509,6 +509,11 @@
/// error. Useful for debugging overloading issues.
void ImplicitConversionSequence::DebugPrint() const {
raw_ostream &OS = llvm::errs();
+ if (isListInitializationSequence()) {
+ OS << "List-initialization sequence: ";
+ if (isStdInitializerListElement())
+ OS << "Worst std::initializer_list element conversion: ";
+ }
switch (ConversionKind) {
case StandardConversion:
OS << "Standard conversion: ";
@@ -4524,11 +4529,13 @@
= S.CompareReferenceRelationship(From->getLocStart(), T1, T2, dummy1,
dummy2, dummy3);
- if (RefRelationship >= Sema::Ref_Related)
- return TryReferenceInit(S, Init, ToType,
- /*FIXME:*/From->getLocStart(),
- SuppressUserConversions,
- /*AllowExplicit=*/false);
+ if (RefRelationship >= Sema::Ref_Related) {
+ Result = TryReferenceInit(S, Init, ToType, /*FIXME*/From->getLocStart(),
+ SuppressUserConversions,
+ /*AllowExplicit=*/false);
+ Result.setListInitializationSequence();
+ return Result;
+ }
}
// Otherwise, we bind the reference to a temporary created from the