blob: 9a1fa76c622acb9f398070439ed37d2fc27d128f [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -emit-llvm -o %t %s &&
Daniel Dunbar6bfed7e2008-08-01 00:01:51 +00002// RUN: grep -e "global_ctors.*@A" %t &&
Daniel Dunbar73241df2009-02-13 21:18:01 +00003// RUN: grep -e "global_dtors.*@B" %t &&
4// RUN: grep -e "global_ctors.*@C" %t &&
5// RUN: grep -e "global_dtors.*@D" %t
Daniel Dunbar6bfed7e2008-08-01 00:01:51 +00006
7#include <stdio.h>
8
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}