r190115 - When creating an implicit conversion sequence for a reference of type T from an
Richard Smith
richard-llvm at metafoo.co.uk
Thu Sep 5 18:22:42 PDT 2013
Author: rsmith
Date: Thu Sep 5 20:22:42 2013
New Revision: 190115
URL: http://llvm.org/viewvc/llvm-project?rev=190115&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=190115&r1=190114&r2=190115&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Sep 5 20:22:42 2013
@@ -509,6 +509,11 @@ void UserDefinedConversionSequence::Debu
/// 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 @@ TryListConversion(Sema &S, InitListExpr
= 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
Modified: cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp?rev=190115&r1=190114&r2=190115&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp Thu Sep 5 20:22:42 2013
@@ -218,3 +218,10 @@ namespace deleted_copy {
std::initializer_list<X> x{1}; // expected-error {{invokes deleted constructor}}
}
+
+namespace RefVersusInitList {
+ struct S {};
+ void f(const S &) = delete;
+ void f(std::initializer_list<S>);
+ void g(S s) { f({S()}); }
+}
More information about the cfe-commits
mailing list