blob: b3d0cb54d15c5e0b013c413dc8e80157fac95e5e [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -emit-llvm %s -o %t
Devang Patel8e53e722007-10-26 16:31:40 +00002
3int A[10] = { 1,2,3,4,5 };
4
Chris Lattner9cd4fe42007-12-02 07:09:19 +00005
6extern int x[];
7void foo() { x[0] = 1; }
8int x[10];
9void bar() { x[0] = 1; }
10
Chris Lattner9615bf82007-12-02 07:30:13 +000011
Chris Lattnere6e25a52007-12-02 07:46:00 +000012extern int y[];
Chris Lattner4fd46bc2007-12-10 19:50:32 +000013void *g = y;
Chris Lattner9615bf82007-12-02 07:30:13 +000014
Chris Lattner2ea81a82007-12-09 00:36:01 +000015int latin_ptr2len (char *p);
16int (*mb_ptr2len) (char *p) = latin_ptr2len;
17
Chris Lattnera44cf732007-12-09 23:49:42 +000018
Chris Lattnerdf5eb712007-12-11 01:38:45 +000019char string[8] = "string"; // extend init
20char string2[4] = "string"; // truncate init
Chris Lattnera44cf732007-12-09 23:49:42 +000021
Chris Lattner2b9d2ca2007-12-18 08:16:44 +000022char *test(int c) {
23 static char buf[10];
24 static char *bufptr = buf;
25
26 return c ? buf : bufptr;
27}
28
Chris Lattner19009e62008-01-09 18:47:25 +000029
30_Bool booltest = 0;
31void booltest2() {
32 static _Bool booltest3 = 4;
33}
34
Anders Carlssona3881fc2008-01-29 01:28:48 +000035// Scalars in braces.
36static int a = { 1 };
Anders Carlssona3881fc2008-01-29 01:28:48 +000037
Anders Carlssonce6237e2008-01-29 01:33:32 +000038// References to enums.
Anders Carlssona3881fc2008-01-29 01:28:48 +000039enum {
Mike Stump1eb44332009-09-09 15:08:12 +000040 EnumA, EnumB
Anders Carlssona3881fc2008-01-29 01:28:48 +000041};
42
43int c[] = { EnumA, EnumB };
Anders Carlssonce6237e2008-01-29 01:33:32 +000044
45// Binary operators
46int d[] = { EnumA | EnumB };
Chris Lattnerc4b23a52008-02-05 06:37:34 +000047
48// PR1968
49static int array[];
50static int array[4];
51