diff options
Diffstat (limited to 'test/crt/dso_handle.cpp')
-rw-r--r-- | test/crt/dso_handle.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/crt/dso_handle.cpp b/test/crt/dso_handle.cpp new file mode 100644 index 000000000..c08ed9c0e --- /dev/null +++ b/test/crt/dso_handle.cpp @@ -0,0 +1,33 @@ +// RUN: %clangxx -g -DCRT_SHARED -c %s -fPIC -o %tshared.o +// RUN: %clangxx -g -c %s -fPIC -o %t.o +// RUN: %clangxx -g -shared -o %t.so -nostdlib %crti %crtbegin %tshared.o %libstdcxx -lc -lm %libgcc %crtend %crtn +// RUN: %clangxx -g -o %t -nostdlib %crt1 %crti %crtbegin %t.o %libstdcxx -lc -lm %libgcc %t.so %crtend %crtn +// RUN: %run %t 2>&1 | FileCheck %s + +#include <stdio.h> + +// CHECK: 1 +// CHECK-NEXT: ~A() + +#ifdef CRT_SHARED +bool G; +void C() { + printf("%d\n", G); +} + +struct A { + A() { G = true; } + ~A() { + printf("~A()\n"); + } +}; + +A a; +#else +void C(); + +int main() { + C(); + return 0; +} +#endif |