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