Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -emit-llvm %s -o %t |
Devang Patel | 8e53e72 | 2007-10-26 16:31:40 +0000 | [diff] [blame] | 2 | |
3 | int A[10] = { 1,2,3,4,5 }; | ||||
4 | |||||
Chris Lattner | 9cd4fe4 | 2007-12-02 07:09:19 +0000 | [diff] [blame] | 5 | |
6 | extern int x[]; | ||||
7 | void foo() { x[0] = 1; } | ||||
8 | int x[10]; | ||||
9 | void bar() { x[0] = 1; } | ||||
10 | |||||
Chris Lattner | 9615bf8 | 2007-12-02 07:30:13 +0000 | [diff] [blame] | 11 | |
Chris Lattner | e6e25a5 | 2007-12-02 07:46:00 +0000 | [diff] [blame] | 12 | extern int y[]; |
Chris Lattner | 4fd46bc | 2007-12-10 19:50:32 +0000 | [diff] [blame] | 13 | void *g = y; |
Chris Lattner | 9615bf8 | 2007-12-02 07:30:13 +0000 | [diff] [blame] | 14 | |
Chris Lattner | 2ea81a8 | 2007-12-09 00:36:01 +0000 | [diff] [blame] | 15 | int latin_ptr2len (char *p); |
16 | int (*mb_ptr2len) (char *p) = latin_ptr2len; | ||||
17 | |||||
Chris Lattner | a44cf73 | 2007-12-09 23:49:42 +0000 | [diff] [blame] | 18 | |
Chris Lattner | df5eb71 | 2007-12-11 01:38:45 +0000 | [diff] [blame] | 19 | char string[8] = "string"; // extend init |
20 | char string2[4] = "string"; // truncate init | ||||
Chris Lattner | a44cf73 | 2007-12-09 23:49:42 +0000 | [diff] [blame] | 21 | |
Chris Lattner | 2b9d2ca | 2007-12-18 08:16:44 +0000 | [diff] [blame] | 22 | char *test(int c) { |
23 | static char buf[10]; | ||||
24 | static char *bufptr = buf; | ||||
25 | |||||
26 | return c ? buf : bufptr; | ||||
27 | } | ||||
28 | |||||
Chris Lattner | 19009e6 | 2008-01-09 18:47:25 +0000 | [diff] [blame] | 29 | |
30 | _Bool booltest = 0; | ||||
31 | void booltest2() { | ||||
32 | static _Bool booltest3 = 4; | ||||
33 | } | ||||
34 | |||||
Anders Carlsson | a3881fc | 2008-01-29 01:28:48 +0000 | [diff] [blame] | 35 | // Scalars in braces. |
36 | static int a = { 1 }; | ||||
Anders Carlsson | a3881fc | 2008-01-29 01:28:48 +0000 | [diff] [blame] | 37 | |
Anders Carlsson | ce6237e | 2008-01-29 01:33:32 +0000 | [diff] [blame] | 38 | // References to enums. |
Anders Carlsson | a3881fc | 2008-01-29 01:28:48 +0000 | [diff] [blame] | 39 | enum { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame^] | 40 | EnumA, EnumB |
Anders Carlsson | a3881fc | 2008-01-29 01:28:48 +0000 | [diff] [blame] | 41 | }; |
42 | |||||
43 | int c[] = { EnumA, EnumB }; | ||||
Anders Carlsson | ce6237e | 2008-01-29 01:33:32 +0000 | [diff] [blame] | 44 | |
45 | // Binary operators | ||||
46 | int d[] = { EnumA | EnumB }; | ||||
Chris Lattner | c4b23a5 | 2008-02-05 06:37:34 +0000 | [diff] [blame] | 47 | |
48 | // PR1968 | ||||
49 | static int array[]; | ||||
50 | static int array[4]; | ||||
51 |