Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / AST / Interp / lifetimes.cpp
blobc1046e568920750ecb90d42858b09484a8893ec3
1 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
2 // RUN: %clang_cc1 -verify=ref %s
4 struct Foo {
5 int a;
6 };
8 constexpr int dead1() { // expected-error {{never produces a constant expression}}
10 Foo *F2 = nullptr;
12 Foo F{12}; // expected-note 2{{declared here}}
13 F2 = &F;
14 } // Ends lifetime of F.
16 return F2->a; // expected-note 2{{read of variable whose lifetime has ended}} \
17 // ref-note {{read of object outside its lifetime is not allowed in a constant expression}}
19 static_assert(dead1() == 1, ""); // expected-error {{not an integral constant expression}} \
20 // expected-note {{in call to}} \
21 // ref-error {{not an integral constant expression}} \
22 // ref-note {{in call to}} \