blob: a1f0e604d401e2c957bf935ce302180fef08147c [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -emit-llvm -o %t %s
Daniel Dunbar4fcfde42009-11-08 01:45:36 +00002// RUN: grep -e "global_ctors.*@A" %t
3// RUN: grep -e "global_dtors.*@B" %t
4// RUN: grep -e "global_ctors.*@C" %t
Daniel Dunbar73241df2009-02-13 21:18:01 +00005// RUN: grep -e "global_dtors.*@D" %t
Daniel Dunbar6bfed7e2008-08-01 00:01:51 +00006
Daniel Dunbar23afaad2009-11-17 08:57:36 +00007int printf(const char *, ...);
Daniel Dunbar6bfed7e2008-08-01 00:01:51 +00008
9void A() __attribute__((constructor));
10void B() __attribute__((destructor));
11
12void A() {
13 printf("A\n");
14}
15
16void B() {
17 printf("B\n");
18}
19
Daniel Dunbar73241df2009-02-13 21:18:01 +000020static void C() __attribute__((constructor));
21
22static void D() __attribute__((destructor));
23
24static int foo() {
25 return 10;
26}
27
28static void C() {
29 printf("A: %d\n", foo());
30}
31
32static void D() {
33 printf("B\n");
34}
35
Daniel Dunbar6bfed7e2008-08-01 00:01:51 +000036int main() {
37 return 0;
38}