Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm -o %t %s |
Daniel Dunbar | 03f5ad9 | 2009-04-15 22:08:45 +0000 | [diff] [blame] | 2 | |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 3 | // RUN: grep '@r = common global \[1 x .*\] zeroinitializer' %t |
Daniel Dunbar | 03f5ad9 | 2009-04-15 22:08:45 +0000 | [diff] [blame] | 4 | |
| 5 | int r[]; |
| 6 | int (*a)[] = &r; |
| 7 | |
| 8 | struct s0; |
| 9 | struct s0 x; |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 10 | // RUN: grep '@x = common global .struct.s0 zeroinitializer' %t |
Daniel Dunbar | 03f5ad9 | 2009-04-15 22:08:45 +0000 | [diff] [blame] | 11 | |
| 12 | struct s0 y; |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 13 | // RUN: grep '@y = common global .struct.s0 zeroinitializer' %t |
Daniel Dunbar | 03f5ad9 | 2009-04-15 22:08:45 +0000 | [diff] [blame] | 14 | struct s0 *f0() { |
| 15 | return &y; |
| 16 | } |
| 17 | |
| 18 | struct s0 { |
| 19 | int x; |
| 20 | }; |
| 21 | |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 22 | // RUN: grep '@b = common global \[1 x .*\] zeroinitializer' %t |
Daniel Dunbar | 03f5ad9 | 2009-04-15 22:08:45 +0000 | [diff] [blame] | 23 | int b[]; |
| 24 | int *f1() { |
| 25 | return b; |
| 26 | } |
| 27 | |
Daniel Dunbar | 6463ef4 | 2009-04-16 15:34:14 +0000 | [diff] [blame] | 28 | // Check that the most recent tentative definition wins. |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 29 | // RUN: grep '@c = common global \[4 x .*\] zeroinitializer' %t |
Daniel Dunbar | 6463ef4 | 2009-04-16 15:34:14 +0000 | [diff] [blame] | 30 | int c[]; |
| 31 | int c[4]; |
| 32 | |
Douglas Gregor | ebe9411 | 2009-05-01 15:45:53 +0000 | [diff] [blame] | 33 | // Check that we emit static tentative definitions |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 34 | // RUN: grep '@c5 = internal global \[1 x .*\] zeroinitializer' %t |
Douglas Gregor | ebe9411 | 2009-05-01 15:45:53 +0000 | [diff] [blame] | 35 | static int c5[]; |
| 36 | static int func() { return c5[0]; } |
| 37 | int callfunc() { return func(); } |
| 38 | |