summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2018-07-17 00:11:41 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2018-07-17 00:11:41 +0000
commit0a9969b36b16307e6cf60004b108be972c93d336 (patch)
treeb9e216b9ac175f3a86b748a5effc1190bb161793 /clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
parent1c1de452570b525f1a7ed9f7da919e0af16c23bd (diff)
downloadbcm5719-llvm-0a9969b36b16307e6cf60004b108be972c93d336.tar.gz
bcm5719-llvm-0a9969b36b16307e6cf60004b108be972c93d336.zip
Restructure checking for, and warning on, lifetime extension.
This change implements C++ DR1696, which makes initialization of a reference member of a class from a temporary object ill-formed. The standard wording here is imprecise, but we interpret it as meaning that any time a mem-initializer would result in lifetime extension, the program is ill-formed. llvm-svn: 337226
Diffstat (limited to 'clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp')
-rw-r--r--clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
index 860a4aa6c6f..ece014d93a5 100644
--- a/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ b/clang/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -153,13 +153,14 @@ void dangle() {
}
struct haslist1 {
- std::initializer_list<int> il = {1, 2, 3}; // expected-warning{{at the end of the constructor}}
- std::initializer_list<int> jl{1, 2, 3}; // expected-warning{{at the end of the constructor}}
+ std::initializer_list<int> il // expected-note {{declared here}}
+ = {1, 2, 3}; // ok, unused
+ std::initializer_list<int> jl{1, 2, 3}; // expected-error {{backing array for 'std::initializer_list' member 'jl' is a temporary object}}
haslist1();
};
-haslist1::haslist1()
-: il{1, 2, 3} // expected-warning{{at the end of the constructor}}
+haslist1::haslist1() // expected-note {{used here}}
+: il{1, 2, 3} // expected-error {{backing array for 'std::initializer_list' member 'il' is a temporary object}}
{}
namespace PR12119 {
OpenPOWER on IntegriCloud