Shih-wei Liao | f8fd82b | 2010-02-10 11:10:31 -0800 | [diff] [blame^] | 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 | |
| 12 | void A() { |
| 13 | printf("A\n"); |
| 14 | } |
| 15 | |
| 16 | void B() { |
| 17 | printf("B\n"); |
| 18 | } |
| 19 | |
| 20 | static void C() __attribute__((constructor)); |
| 21 | |
| 22 | static void D() __attribute__((destructor)); |
| 23 | |
| 24 | static int foo() { |
| 25 | return 10; |
| 26 | } |
| 27 | |
| 28 | static void C() { |
| 29 | printf("A: %d\n", foo()); |
| 30 | } |
| 31 | |
| 32 | static void D() { |
| 33 | printf("B\n"); |
| 34 | } |
| 35 | |
| 36 | int main() { |
| 37 | return 0; |
| 38 | } |