[cfe-commits] r154065 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
Douglas Gregor
dgregor at apple.com
Wed Apr 4 16:09:21 PDT 2012
Author: dgregor
Date: Wed Apr 4 18:09:20 2012
New Revision: 154065
URL: http://llvm.org/viewvc/llvm-project?rev=154065&view=rev
Log:
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.
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=154065&r1=154064&r2=154065&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Apr 4 18:09:20 2012
@@ -4301,6 +4301,16 @@
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;
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=154065&r1=154064&r2=154065&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp Wed Apr 4 18:09:20 2012
@@ -166,3 +166,12 @@
for( auto s : {"A", "BB", "CCC", "DDD"}) { }
}
}
+
+namespace PR12436 {
+ struct X {
+ template<typename T>
+ X(std::initializer_list<int>, T);
+ };
+
+ X x({}, 17);
+}
More information about the cfe-commits
mailing list