forked from OSchip/llvm-project
Allow a conversion from the empty initializer list {} to an
std::initializer_list<T> so long as <T> is known. This conversion has identity rank. llvm-svn: 154065
This commit is contained in:
parent
bea0d04f8c
commit
0f5c1c0127
|
@ -4301,6 +4301,16 @@ TryListConversion(Sema &S, InitListExpr *From, QualType ToType,
|
|||
ImplicitConversionSequence::Worse)
|
||||
Result = ICS;
|
||||
}
|
||||
|
||||
// For an empty list, we won't have computed any conversion sequence.
|
||||
// Introduce the identity conversion sequence.
|
||||
if (From->getNumInits() == 0) {
|
||||
Result.setStandard();
|
||||
Result.Standard.setAsIdentityConversion();
|
||||
Result.Standard.setFromType(ToType);
|
||||
Result.Standard.setAllToTypes(ToType);
|
||||
}
|
||||
|
||||
Result.setListInitializationSequence();
|
||||
Result.setStdInitializerListElement(toStdInitializerList);
|
||||
return Result;
|
||||
|
|
|
@ -166,3 +166,12 @@ namespace Decay {
|
|||
for( auto s : {"A", "BB", "CCC", "DDD"}) { }
|
||||
}
|
||||
}
|
||||
|
||||
namespace PR12436 {
|
||||
struct X {
|
||||
template<typename T>
|
||||
X(std::initializer_list<int>, T);
|
||||
};
|
||||
|
||||
X x({}, 17);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue