Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm -o %t %s |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 2 | // RUN: grep -e "global_ctors.*@A" %t |
| 3 | // RUN: grep -e "global_dtors.*@B" %t |
| 4 | // RUN: grep -e "global_ctors.*@C" %t |
Daniel Dunbar | 73241df | 2009-02-13 21:18:01 +0000 | [diff] [blame] | 5 | // RUN: grep -e "global_dtors.*@D" %t |
Daniel Dunbar | 6bfed7e | 2008-08-01 00:01:51 +0000 | [diff] [blame] | 6 | |
Daniel Dunbar | 23afaad | 2009-11-17 08:57:36 +0000 | [diff] [blame] | 7 | int printf(const char *, ...); |
Daniel Dunbar | 6bfed7e | 2008-08-01 00:01:51 +0000 | [diff] [blame] | 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 | |
Daniel Dunbar | 73241df | 2009-02-13 21:18:01 +0000 | [diff] [blame] | 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 | |
Daniel Dunbar | 6bfed7e | 2008-08-01 00:01:51 +0000 | [diff] [blame] | 36 | int main() { |
| 37 | return 0; |
| 38 | } |