mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 03:29:40 +00:00
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7335 91177308-0d34-0410-b5e6-96231b3b80d8
46 lines
920 B
C
46 lines
920 B
C
/* Test globals used and unused within different parts of a program */
|
|
|
|
/* FIXME: This testcase should be automated */
|
|
|
|
#include <stdlib.h>
|
|
|
|
extern void exit_dummy(int*);
|
|
|
|
static int** G;
|
|
static int N, M;
|
|
|
|
void
|
|
foo(int *Z) /* accesses globals printf and format string, and */
|
|
{ /* N = alloca(int) from test() */
|
|
if (Z == 0) exit_dummy(Z); /* call to external function */
|
|
++*Z;
|
|
printf("N = %d\n", *Z);
|
|
}
|
|
|
|
void leaf2(int* Y)
|
|
{
|
|
if (Y == 0) exit_dummy(Y); /* second call to external function */
|
|
}
|
|
|
|
void
|
|
test(int* X) /* accesses global G */
|
|
{ /* allocates G = malloc(int*) and N = alloca(int) */
|
|
if (X == 0)
|
|
X = &N;
|
|
G = (int**) alloca(sizeof(int*));
|
|
*G = &N;
|
|
**G = 10;
|
|
foo(*G);
|
|
leaf2(*G);
|
|
*X = **G;
|
|
/* free(G); */
|
|
}
|
|
|
|
int
|
|
main() /* only accesses global N */
|
|
{
|
|
/* N = 0; */
|
|
test(0 /*&N*/);
|
|
return 0;
|
|
}
|