1 // UNSUPPORTED: system-aix, system-zos 2 // see https://github.com/llvm/llvm-project/issues/68092 3 // XFAIL: host={{.*}}-windows-msvc 4 5 // The test is flaky with asan https://github.com/llvm/llvm-project/issues/102858. 6 // UNSUPPORTED: asan 7 8 // RUN: cat %s | clang-repl | FileCheck %s 9 // RUN: cat %s | clang-repl -Xcc -O2 | FileCheck %s 10 11 extern "C" int printf(const char*, ...); 12 13 struct A { int val; A(int v); ~A(); void f() const; }; 14 A::A(int v) : val(v) { printf("A(%d), this = %p\n", val, this); } 15 A::~A() { printf("~A, this = %p, val = %d\n", this, val); } 16 void A::f() const { printf("f: this = %p, val = %d\n", this, val); } 17 18 const A a(1); 19 // CHECK: A(1), this = [[THIS:.+]] 20 // The constructor must only be called once! 21 // CHECK-NOT: A(1) 22 23 a.f(); 24 // CHECK-NEXT: f: this = [[THIS]], val = 1 25 a.f(); 26 // CHECK-NEXT: f: this = [[THIS]], val = 1 27 28 %quit 29 // There must still be no other constructor! 30 // CHECK-NOT: A(1) 31 32 // At the end, we expect exactly one destructor call 33 // CHECK: ~A 34 // CHECK-SAME: this = [[THIS]], val = 1 35 // CHECK-NOT: ~A 36