1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -triple armv7-none-eabi -emit-llvm -o - %s | FileCheck %s
2f4a2713aSLionel Sambuc
3f4a2713aSLionel Sambuc struct X {
4f4a2713aSLionel Sambuc X();
5f4a2713aSLionel Sambuc X(const X&);
6f4a2713aSLionel Sambuc X(const char*);
7f4a2713aSLionel Sambuc ~X();
8f4a2713aSLionel Sambuc };
9f4a2713aSLionel Sambuc
10f4a2713aSLionel Sambuc struct Y {
11f4a2713aSLionel Sambuc int i;
12f4a2713aSLionel Sambuc X x;
13f4a2713aSLionel Sambuc };
14f4a2713aSLionel Sambuc
15f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z1fv()
f()16f4a2713aSLionel Sambuc int f() {
17f4a2713aSLionel Sambuc // CHECK: [[LVALUE:%[a-z0-9.]+]] = alloca
18f4a2713aSLionel Sambuc // CHECK-NEXT: [[I:%[a-z0-9]+]] = getelementptr inbounds {{.*}}* [[LVALUE]], i32 0, i32 0
19f4a2713aSLionel Sambuc // CHECK-NEXT: store i32 17, i32* [[I]]
20f4a2713aSLionel Sambuc // CHECK-NEXT: [[X:%[a-z0-9]+]] = getelementptr inbounds {{.*}} [[LVALUE]], i32 0, i32 1
21f4a2713aSLionel Sambuc // CHECK-NEXT: call %struct.X* @_ZN1XC1EPKc({{.*}}[[X]]
22f4a2713aSLionel Sambuc // CHECK-NEXT: [[I:%[a-z0-9]+]] = getelementptr inbounds {{.*}} [[LVALUE]], i32 0, i32 0
23f4a2713aSLionel Sambuc // CHECK-NEXT: [[RESULT:%[a-z0-9]+]] = load i32*
24f4a2713aSLionel Sambuc // CHECK-NEXT: call %struct.Y* @_ZN1YD1Ev
25f4a2713aSLionel Sambuc // CHECK-NEXT: ret i32 [[RESULT]]
26f4a2713aSLionel Sambuc return ((Y){17, "seventeen"}).i;
27f4a2713aSLionel Sambuc }
28f4a2713aSLionel Sambuc
29f4a2713aSLionel Sambuc // CHECK-LABEL: define i32 @_Z1gv()
g()30f4a2713aSLionel Sambuc int g() {
31f4a2713aSLionel Sambuc // CHECK: store [2 x i32]* %{{[a-z0-9.]+}}, [2 x i32]** [[V:%[a-z0-9.]+]]
32f4a2713aSLionel Sambuc const int (&v)[2] = (int [2]) {1,2};
33f4a2713aSLionel Sambuc
34f4a2713aSLionel Sambuc // CHECK: [[A:%[a-z0-9.]+]] = load [2 x i32]** [[V]]
35f4a2713aSLionel Sambuc // CHECK-NEXT: [[A0ADDR:%[a-z0-9.]+]] = getelementptr inbounds [2 x i32]* [[A]], i32 0, {{.*}} 0
36f4a2713aSLionel Sambuc // CHECK-NEXT: [[A0:%[a-z0-9.]+]] = load i32* [[A0ADDR]]
37f4a2713aSLionel Sambuc // CHECK-NEXT: ret i32 [[A0]]
38f4a2713aSLionel Sambuc return v[0];
39f4a2713aSLionel Sambuc }
40f4a2713aSLionel Sambuc
41f4a2713aSLionel Sambuc struct Z { int i[3]; };
42f4a2713aSLionel Sambuc int *p = (Z){ {1, 2, 3} }.i;
43f4a2713aSLionel Sambuc // CHECK: define {{.*}}__cxx_global_var_init()
44f4a2713aSLionel Sambuc // CHECK: store i32* getelementptr inbounds (%struct.Z* @.compoundliteral, i32 0, i32 0, i32 0), i32** @p
45*0a6a1f1dSLionel Sambuc
46*0a6a1f1dSLionel Sambuc
47*0a6a1f1dSLionel Sambuc int *PR21912_1 = (int []){};
48*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define {{.*}}__cxx_global_var_init1()
49*0a6a1f1dSLionel Sambuc // CHECK: store i32* getelementptr inbounds ([0 x i32]* @.compoundliteral2, i32 0, i32 0), i32** @PR21912_1
50*0a6a1f1dSLionel Sambuc
51*0a6a1f1dSLionel Sambuc union PR21912Ty {
52*0a6a1f1dSLionel Sambuc long long l;
53*0a6a1f1dSLionel Sambuc double d;
54*0a6a1f1dSLionel Sambuc };
55*0a6a1f1dSLionel Sambuc union PR21912Ty *PR21912_2 = (union PR21912Ty[]){{.d = 2.0}, {.l = 3}};
56*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define {{.*}}__cxx_global_var_init3()
57*0a6a1f1dSLionel Sambuc // CHECK: store %union.PR21912Ty* getelementptr inbounds ([2 x %union.PR21912Ty]* bitcast (<{ { double }, %union.PR21912Ty }>* @.compoundliteral4 to [2 x %union.PR21912Ty]*), i32 0, i32 0), %union.PR21912Ty** @PR21912_2
58