xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGen/tentative-decls.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -o %t %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // RUN: grep '@r = common global \[1 x .*\] zeroinitializer' %t
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc int r[];
6*f4a2713aSLionel Sambuc int (*a)[] = &r;
7*f4a2713aSLionel Sambuc 
8*f4a2713aSLionel Sambuc struct s0;
9*f4a2713aSLionel Sambuc struct s0 x;
10*f4a2713aSLionel Sambuc // RUN: grep '@x = common global .struct.s0 zeroinitializer' %t
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc struct s0 y;
13*f4a2713aSLionel Sambuc // RUN: grep '@y = common global .struct.s0 zeroinitializer' %t
f0()14*f4a2713aSLionel Sambuc struct s0 *f0() {
15*f4a2713aSLionel Sambuc   return &y;
16*f4a2713aSLionel Sambuc }
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc struct s0 {
19*f4a2713aSLionel Sambuc   int x;
20*f4a2713aSLionel Sambuc };
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc // RUN: grep '@b = common global \[1 x .*\] zeroinitializer' %t
23*f4a2713aSLionel Sambuc int b[];
f1()24*f4a2713aSLionel Sambuc int *f1() {
25*f4a2713aSLionel Sambuc   return b;
26*f4a2713aSLionel Sambuc }
27*f4a2713aSLionel Sambuc 
28*f4a2713aSLionel Sambuc // Check that the most recent tentative definition wins.
29*f4a2713aSLionel Sambuc // RUN: grep '@c = common global \[4 x .*\] zeroinitializer' %t
30*f4a2713aSLionel Sambuc int c[];
31*f4a2713aSLionel Sambuc int c[4];
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc // Check that we emit static tentative definitions
34*f4a2713aSLionel Sambuc // RUN: grep '@c5 = internal global \[1 x .*\] zeroinitializer' %t
35*f4a2713aSLionel Sambuc static int c5[];
func()36*f4a2713aSLionel Sambuc static int func() { return c5[0]; }
callfunc()37*f4a2713aSLionel Sambuc int callfunc() { return func(); }
38*f4a2713aSLionel Sambuc 
39