Skip to content

Commit 398373f

Browse files
Add printf in dtor
1 parent 3aef8a0 commit 398373f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1+
// REQUIRES: host-supports-jit
12
// UNSUPPORTED: system-aix
23

34
// RUN: cat %s | clang-repl | FileCheck %s
45
int *x = new int();
56
template <class T> struct GuardX { T *&x; GuardX(T *&x) : x(x) {}; ~GuardX(); };
6-
template <class T> GuardX<T>::~GuardX() { delete x; x = nullptr; }
77

8-
// clang would normally defer codegen for ~GuardX()
9-
// Make sure that RuntimeInterfaceBuilder requests it explicitly
8+
// clang normally defers codegen for this out-of-line ~GuardX(), which would
9+
// cause the JIT to report Symbols not found: [ _ZN6GuardXIiED2Ev ]
10+
extern "C" int printf(const char *, ...);
11+
template <class T> GuardX<T>::~GuardX() { delete x; printf("Running dtor\n"); }
12+
13+
// Let's make sure that the RuntimeInterfaceBuilder requests it explicitly:
1014
(GuardX(x))
1115

1216
// CHECK-NOT: Symbols not found
13-
// CHECK-NOT: _ZN6GuardXIiED2Ev
17+
// CHECK: Running dtor

0 commit comments

Comments
 (0)