From 0a9969b36b16307e6cf60004b108be972c93d336 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 17 Jul 2018 00:11:41 +0000 Subject: 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 --- clang/test/CXX/drs/dr18xx.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'clang/test/CXX/drs/dr18xx.cpp') diff --git a/clang/test/CXX/drs/dr18xx.cpp b/clang/test/CXX/drs/dr18xx.cpp index a0f470ed4a2..f6a4676bc7b 100644 --- a/clang/test/CXX/drs/dr18xx.cpp +++ b/clang/test/CXX/drs/dr18xx.cpp @@ -30,6 +30,17 @@ namespace dr1813 { // dr1813: 7 static_assert(!__is_standard_layout(U), ""); } +namespace dr1815 { // dr1815: no +#if __cplusplus >= 201402L + // FIXME: needs codegen test + struct A { int &&r = 0; }; // FIXME expected-warning {{not supported}} + A a = {}; // expected-note {{here}} + + struct B { int &&r = 0; }; // expected-error {{binds to a temporary}} expected-note {{here}} + B b; // expected-note {{here}} +#endif +} + namespace dr1881 { // dr1881: 7 struct A { int a : 4; }; struct B : A { int b : 3; }; -- cgit v1.2.3