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