1 // RUN: %clangxx -g -DCRT_SHARED -c %s -fPIC -o %tshared.o 2 // RUN: %clangxx -g -c %s -fPIC -o %t.o 3 // RUN: %clangxx -g -shared -o %t.so -nostdlib %crti %crtbegin %tshared.o %libstdcxx -lc -lm %libgcc %crtend %crtn 4 // RUN: %clangxx -g -o %t -fno-pic -no-pie -nostdlib %crt1 %crti %crtbegin %t.o %libstdcxx -lc -lm %libgcc %t.so %crtend %crtn 5 // RUN: %run %t 2>&1 | FileCheck %s 6 7 // UNSUPPORTED: arm, aarch64 8 9 #include <stdio.h> 10 11 // CHECK: 1 12 // CHECK-NEXT: ~A() 13 14 #ifdef CRT_SHARED 15 bool G; 16 void C() { 17 printf("%d\n", G); 18 } 19 20 struct A { 21 A() { G = true; } 22 ~A() { 23 printf("~A()\n"); 24 } 25 }; 26 27 A a; 28 #else 29 void C(); 30 31 int main() { 32 C(); 33 return 0; 34 } 35 #endif 36