1 // RUN: %clang_cc1 -emit-llvm -o %t %s 2 // RUN: grep -e "global_ctors.*@A" %t 3 // RUN: grep -e "global_dtors.*@B" %t 4 // RUN: grep -e "global_ctors.*@C" %t 5 // RUN: grep -e "global_dtors.*@D" %t 6 7 int printf(const char *, ...); 8 9 void A() __attribute__((constructor)); 10 void B() __attribute__((destructor)); 11 A()12void A() { 13 printf("A\n"); 14 } 15 B()16void B() { 17 printf("B\n"); 18 } 19 20 static void C() __attribute__((constructor)); 21 22 static void D() __attribute__((destructor)); 23 foo()24static int foo() { 25 return 10; 26 } 27 C()28static void C() { 29 printf("A: %d\n", foo()); 30 } 31 D()32static void D() { 33 printf("B\n"); 34 } 35 main()36int main() { 37 return 0; 38 } 39