xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/globalinit.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm %s -o %t
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc int A[10] = { 1,2,3,4,5 };
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc 
6*f4a2713aSLionel Sambuc extern int x[];
foo()7*f4a2713aSLionel Sambuc void foo() { x[0] = 1; }
8*f4a2713aSLionel Sambuc int x[10];
bar()9*f4a2713aSLionel Sambuc void bar() { x[0] = 1; }
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc extern int y[];
13*f4a2713aSLionel Sambuc void *g = y;
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc int latin_ptr2len (char *p);
16*f4a2713aSLionel Sambuc int (*mb_ptr2len) (char *p) = latin_ptr2len;
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc char string[8] = "string";   // extend init
20*f4a2713aSLionel Sambuc char string2[4] = "string";  // truncate init
21*f4a2713aSLionel Sambuc 
test(int c)22*f4a2713aSLionel Sambuc char *test(int c) {
23*f4a2713aSLionel Sambuc  static char buf[10];
24*f4a2713aSLionel Sambuc  static char *bufptr = buf;
25*f4a2713aSLionel Sambuc 
26*f4a2713aSLionel Sambuc  return c ? buf : bufptr;
27*f4a2713aSLionel Sambuc }
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc _Bool booltest = 0;
booltest2()31*f4a2713aSLionel Sambuc void booltest2() {
32*f4a2713aSLionel Sambuc   static _Bool booltest3 = 4;
33*f4a2713aSLionel Sambuc }
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc // Scalars in braces.
36*f4a2713aSLionel Sambuc static int a = { 1 };
37*f4a2713aSLionel Sambuc 
38*f4a2713aSLionel Sambuc // References to enums.
39*f4a2713aSLionel Sambuc enum {
40*f4a2713aSLionel Sambuc   EnumA, EnumB
41*f4a2713aSLionel Sambuc };
42*f4a2713aSLionel Sambuc 
43*f4a2713aSLionel Sambuc int c[] = { EnumA, EnumB };
44*f4a2713aSLionel Sambuc 
45*f4a2713aSLionel Sambuc // Binary operators
46*f4a2713aSLionel Sambuc int d[] = { EnumA | EnumB };
47*f4a2713aSLionel Sambuc 
48*f4a2713aSLionel Sambuc // PR1968
49*f4a2713aSLionel Sambuc static int array[];
50*f4a2713aSLionel Sambuc static int array[4];
51*f4a2713aSLionel Sambuc 
52