1 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify=expected,both %s
2 // RUN: %clang_cc1 -verify=ref,both %s
4 /// FIXME: Slight difference in diagnostic output here.
10 constexpr int dead1() { // expected-error {{never produces a constant expression}}
14 Foo F
{12}; // expected-note 2{{declared here}}
16 } // Ends lifetime of F.
18 return F2
->a
; // expected-note 2{{read of variable whose lifetime has ended}} \
19 // ref-note {{read of object outside its lifetime is not allowed in a constant expression}}
21 static_assert(dead1() == 1, ""); // both-error {{not an integral constant expression}} \
22 // both-note {{in call to}}
26 int &&r
; // both-note {{reference member declared here}}
28 constexpr S() : r(0), t(r
) {} // both-error {{reference member 'r' binds to a temporary object whose lifetime would be shorter than the lifetime of the constructed object}} \
29 // ref-note {{read of object outside its lifetime is not allowed in a constant expression}} \
30 // expected-note {{temporary created here}} \
31 // expected-note {{read of temporary whose lifetime has ended}}
33 constexpr int k1
= S().t
; // both-error {{must be initialized by a constant expression}} \
34 // ref-note {{in call to}} \
35 // expected-note {{in call to}}
38 namespace MoveFnWorks
{
39 template<typename T
> constexpr T
&&ref(T
&&t
) { return (T
&&)t
; }
44 constexpr A(Buf
&buf
) : buf(buf
) { }
48 constexpr bool dtor_calls_dtor() {
51 constexpr B(Buf
&buf
) : d(ref(A(buf
))) {}
61 static_assert(dtor_calls_dtor(), "");
64 namespace PrimitiveMoveFn
{
65 /// This used to crash.