xref: /aosp_15_r20/external/clang/test/CodeGen/pr3518.c (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
2*67e74705SXin Li // PR 3518
3*67e74705SXin Li // Some of the objects were coming out as unintialized (external) before 3518
4*67e74705SXin Li // was fixed.  Internal names are different between llvm-gcc and clang so they
5*67e74705SXin Li // are not tested.
6*67e74705SXin Li 
7*67e74705SXin Li extern void abort (void);
8*67e74705SXin Li 
9*67e74705SXin Li // CHECK: @.compoundliteral = internal global %struct.A { i32 1, i32 2 }
10*67e74705SXin Li // CHECK: @.compoundliteral.1 = internal global %struct.A { i32 3, i32 4 }
11*67e74705SXin Li // CHECK: @.compoundliteral.2 = internal global %struct.B { %struct.A* @.compoundliteral, %struct.A* @.compoundliteral.1 }
12*67e74705SXin Li // CHECK: @.compoundliteral.3 = internal global %struct.A { i32 5, i32 6 }
13*67e74705SXin Li 
14*67e74705SXin Li struct A { int i; int j; };
15*67e74705SXin Li struct B { struct A *a; struct A *b; };
16*67e74705SXin Li struct C { struct B *c; struct A *d; };
17*67e74705SXin Li struct C e = { &(struct B) { &(struct A) { 1, 2 }, &(struct A) { 3, 4 } }, &(struct A) { 5, 6 } };
18*67e74705SXin Li 
19*67e74705SXin Li int
main(void)20*67e74705SXin Li main (void)
21*67e74705SXin Li {
22*67e74705SXin Li   if (e.c->a->i != 1 || e.c->a->j != 2)
23*67e74705SXin Li     abort ();
24*67e74705SXin Li   if (e.c->b->i != 3 || e.c->b->j != 4)
25*67e74705SXin Li     abort ();
26*67e74705SXin Li   if (e.d->i != 5 || e.d->j != 6)
27*67e74705SXin Li     abort ();
28*67e74705SXin Li   return 0;
29*67e74705SXin Li }
30