xref: /llvm-project/clang/test/Interpreter/inline-virtual.cpp (revision c63b9a5af72a7d83d936c12ae4bc79828c073edf)
1 // REQUIRES: host-supports-jit
2 // UNSUPPORTED: system-aix
3 //
4 // We disable RTTI to avoid problems on Windows for non-RTTI builds of LLVM
5 // where the JIT cannot find ??_7type_info@@6B@.
6 // RUN: cat %s | clang-repl -Xcc -fno-rtti -Xcc -fno-sized-deallocation \
7 // RUN:     | FileCheck %s
8 // RUN: cat %s | clang-repl -Xcc -fno-rtti -Xcc -fno-sized-deallocation \
9 // RUN:     -Xcc -O2 | FileCheck %s
10 
11 extern "C" int printf(const char *, ...);
12 
AA13 struct A { int a; A(int a) : a(a) {} virtual ~A(); };
14 
15 // Then define the virtual destructor as inline out-of-line, in a separate
16 // PartialTranslationUnit.
~A()17 inline A::~A() { printf("~A(%d)\n", a); }
18 
19 // Create one instance with new and delete it. We crash here now:
20 A *a1 = new A(1);
21 delete a1;
22 // CHECK: ~A(1)
23 
24 // Also create one global that will be auto-destructed.
25 A a2(2);
26 // CHECK: ~A(2)
27