blob: d88c346d7c525e8d60179e486e3b55e08710c78f [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -emit-llvm -o %t %s
Daniel Dunbar03f5ad92009-04-15 22:08:45 +00002
Daniel Dunbar4fcfde42009-11-08 01:45:36 +00003// RUN: grep '@r = common global \[1 x .*\] zeroinitializer' %t
Daniel Dunbar03f5ad92009-04-15 22:08:45 +00004
5int r[];
6int (*a)[] = &r;
7
8struct s0;
9struct s0 x;
Daniel Dunbar4fcfde42009-11-08 01:45:36 +000010// RUN: grep '@x = common global .struct.s0 zeroinitializer' %t
Daniel Dunbar03f5ad92009-04-15 22:08:45 +000011
12struct s0 y;
Daniel Dunbar4fcfde42009-11-08 01:45:36 +000013// RUN: grep '@y = common global .struct.s0 zeroinitializer' %t
Daniel Dunbar03f5ad92009-04-15 22:08:45 +000014struct s0 *f0() {
15 return &y;
16}
17
18struct s0 {
19 int x;
20};
21
Daniel Dunbar4fcfde42009-11-08 01:45:36 +000022// RUN: grep '@b = common global \[1 x .*\] zeroinitializer' %t
Daniel Dunbar03f5ad92009-04-15 22:08:45 +000023int b[];
24int *f1() {
25 return b;
26}
27
Daniel Dunbar6463ef42009-04-16 15:34:14 +000028// Check that the most recent tentative definition wins.
Daniel Dunbar4fcfde42009-11-08 01:45:36 +000029// RUN: grep '@c = common global \[4 x .*\] zeroinitializer' %t
Daniel Dunbar6463ef42009-04-16 15:34:14 +000030int c[];
31int c[4];
32
Douglas Gregorebe94112009-05-01 15:45:53 +000033// Check that we emit static tentative definitions
Daniel Dunbar4fcfde42009-11-08 01:45:36 +000034// RUN: grep '@c5 = internal global \[1 x .*\] zeroinitializer' %t
Douglas Gregorebe94112009-05-01 15:45:53 +000035static int c5[];
36static int func() { return c5[0]; }
37int callfunc() { return func(); }
38