Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Interpreter / const.cpp
blob4b6ce65e3643e6460a21d922bfc89cf9ccd88596
1 // UNSUPPORTED: system-aix
2 // see https://github.com/llvm/llvm-project/issues/68092
3 // XFAIL: system-windows
5 // RUN: cat %s | clang-repl | FileCheck %s
6 // RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s
8 extern "C" int printf(const char*, ...);
10 struct A { int val; A(int v); ~A(); void f() const; };
11 A::A(int v) : val(v) { printf("A(%d), this = %p\n", val, this); }
12 A::~A() { printf("~A, this = %p, val = %d\n", this, val); }
13 void A::f() const { printf("f: this = %p, val = %d\n", this, val); }
15 const A a(1);
16 // CHECK: A(1), this = [[THIS:.+]]
17 // The constructor must only be called once!
18 // CHECK-NOT: A(1)
20 a.f();
21 // CHECK-NEXT: f: this = [[THIS]], val = 1
22 a.f();
23 // CHECK-NEXT: f: this = [[THIS]], val = 1
25 %quit
26 // There must still be no other constructor!
27 // CHECK-NOT: A(1)
29 // At the end, we expect exactly one destructor call
30 // CHECK: ~A
31 // CHECK-SAME: this = [[THIS]], val = 1
32 // CHECK-NOT: ~A