summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-11-11 01:36:17 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-11-11 01:36:17 +0000
commit42b10572443e3f3f3c4a113f88ad4e9b504df900 (patch)
treeb826b89beb307ed24b6ffedf840c5605ccabb3f4 /clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
parent754cd11d9019e62a4c6a0aee62159e707f6f51d9 (diff)
downloadbcm5719-llvm-42b10572443e3f3f3c4a113f88ad4e9b504df900.tar.gz
bcm5719-llvm-42b10572443e3f3f3c4a113f88ad4e9b504df900.zip
N3922: direct-list-initialization of an auto-typed variable no longer deduces a
std::initializer_list<T> type. Instead, the list must contain a single element and the type is deduced from that. In Clang 3.7, we warned by default on all the cases that would change meaning due to this change. In Clang 3.8, we will support only the new rules -- per the request in N3922, this change is applied as a Defect Report against earlier versions of the C++ standard. This change is not entirely trivial, because for lambda init-captures we previously did not track the difference between direct-list-initialization and copy-list-initialization. The difference was not previously observable, because the two forms of initialization always did the same thing (the elements of the initializer list were always copy-initialized regardless of the initialization style used for the init-capture). llvm-svn: 252688
Diffstat (limited to 'clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp')
-rw-r--r--clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
index 9456dd713aa..3d119643710 100644
--- a/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -117,8 +117,10 @@ void argument_deduction() {
void auto_deduction() {
auto l = {1, 2, 3, 4};
- auto l2 {1, 2, 3, 4}; // expected-warning {{will change meaning in a future version of Clang}}
+ auto l2 {1, 2, 3, 4}; // expected-error {{initializer for variable 'l2' with type 'auto' contains multiple expressions}}
+ auto l3 {1};
static_assert(same_type<decltype(l), std::initializer_list<int>>::value, "");
+ static_assert(same_type<decltype(l3), int>::value, "");
auto bl = {1, 2.0}; // expected-error {{cannot deduce}}
for (int i : {1, 2, 3, 4}) {}
@@ -190,7 +192,7 @@ namespace rdar11948732 {
}
namespace PR14272 {
- auto x { { 0, 0 } }; // expected-error {{cannot deduce actual type for variable 'x' with type 'auto' from initializer list}}
+ auto x { { 0, 0 } }; // expected-error {{cannot deduce type for variable 'x' with type 'auto' from nested initializer list}}
}
namespace initlist_of_array {
OpenPOWER on IntegriCloud