Add fixmes
[oota-llvm.git] / test / Analysis / DSGraph / globals.c
1 /* Test globals used and unused within different parts of a program */
2
3 /* FIXME: This testcase should be automated */
4
5 #include <stdlib.h>
6
7 extern void exit_dummy(int*);
8
9 static int** G;
10 static int N, M;
11
12 void
13 foo(int *Z)          /* accesses globals printf and format string, and */
14 {                    /* N = alloca(int) from test() */
15   if (Z == 0) exit_dummy(Z);            /* call to external function */
16   ++*Z;
17   printf("N = %d\n", *Z);
18 }
19
20 void leaf2(int* Y)
21 {
22   if (Y == 0) exit_dummy(Y);            /* second call to external function */
23 }
24
25 void
26 test(int* X)         /* accesses global G */
27 {                    /* allocates G = malloc(int*) and N = alloca(int) */
28   if (X == 0)
29     X = &N;
30   G = (int**) alloca(sizeof(int*));
31   *G = &N;
32   **G = 10;
33   foo(*G);
34   leaf2(*G);
35   *X = **G;
36   /* free(G); */
37 }
38
39 int
40 main()               /* only accesses global N */
41 {
42   /* N = 0; */
43   test(0 /*&N*/);
44   return 0;
45 }