xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/const-init-cxx11.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: not %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s -std=c++11 | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // FIXME: The padding in all these objects should be zero-initialized.
4*f4a2713aSLionel Sambuc namespace StructUnion {
5*f4a2713aSLionel Sambuc   struct A {
6*f4a2713aSLionel Sambuc     int n;
7*f4a2713aSLionel Sambuc     double d;
8*f4a2713aSLionel Sambuc     union U {
9*f4a2713aSLionel Sambuc       constexpr U(int x) : x(x) {}
10*f4a2713aSLionel Sambuc       constexpr U(const char *y) : y(y) {}
11*f4a2713aSLionel Sambuc       int x;
12*f4a2713aSLionel Sambuc       const char *y;
13*f4a2713aSLionel Sambuc     } u;
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc     constexpr A(int n, double d, int x) : n(n), d(d), u(x) {}
16*f4a2713aSLionel Sambuc     constexpr A(int n, double d, const char *y) : n(n), d(d), u(y) {}
17*f4a2713aSLionel Sambuc   };
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc   // CHECK: @_ZN11StructUnion1aE = constant {{.*}} { i32 1, double 2.000000e+00, {{.*}} { i32 3, [4 x i8] undef } }
20*f4a2713aSLionel Sambuc   extern constexpr A a(1, 2.0, 3);
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc   // CHECK: @_ZN11StructUnion1bE = constant {{.*}} { i32 4, double 5.000000e+00, {{.*}} { i8* getelementptr inbounds ([6 x i8]* @{{.*}}, i32 0, i32 0) } }
23*f4a2713aSLionel Sambuc   extern constexpr A b(4, 5, "hello");
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc   struct B {
26*f4a2713aSLionel Sambuc     int n;
27*f4a2713aSLionel Sambuc   };
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc   // CHECK: @_ZN11StructUnion1cE = global {{.*}} zeroinitializer
30*f4a2713aSLionel Sambuc   // CHECK: @_ZN11StructUnion2c2E = global {{.*}} zeroinitializer
31*f4a2713aSLionel Sambuc   B c;
32*f4a2713aSLionel Sambuc   B c2 = B();
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc   // CHECK: @_ZN11StructUnion1dE = global {{.*}} zeroinitializer
35*f4a2713aSLionel Sambuc   B d[10];
36*f4a2713aSLionel Sambuc 
37*f4a2713aSLionel Sambuc   struct C {
38*f4a2713aSLionel Sambuc     constexpr C() : c(0) {}
39*f4a2713aSLionel Sambuc     int c;
40*f4a2713aSLionel Sambuc   };
41*f4a2713aSLionel Sambuc 
42*f4a2713aSLionel Sambuc   // CHECK: @_ZN11StructUnion1eE = global {{.*}} zeroinitializer
43*f4a2713aSLionel Sambuc   C e[10];
44*f4a2713aSLionel Sambuc 
45*f4a2713aSLionel Sambuc   struct D {
46*f4a2713aSLionel Sambuc     constexpr D() : d(5) {}
47*f4a2713aSLionel Sambuc     int d;
48*f4a2713aSLionel Sambuc   };
49*f4a2713aSLionel Sambuc 
50*f4a2713aSLionel Sambuc   // CHECK: @_ZN11StructUnion1fE = global {{.*}} { i32 5 }
51*f4a2713aSLionel Sambuc   D f;
52*f4a2713aSLionel Sambuc 
53*f4a2713aSLionel Sambuc   union E {
54*f4a2713aSLionel Sambuc     int a;
55*f4a2713aSLionel Sambuc     void *b = &f;
56*f4a2713aSLionel Sambuc   };
57*f4a2713aSLionel Sambuc 
58*f4a2713aSLionel Sambuc   // CHECK: @_ZN11StructUnion1gE = global {{.*}} @_ZN11StructUnion1fE
59*f4a2713aSLionel Sambuc   E g;
60*f4a2713aSLionel Sambuc 
61*f4a2713aSLionel Sambuc   // CHECK: @_ZN11StructUnion1hE = global {{.*}} @_ZN11StructUnion1fE
62*f4a2713aSLionel Sambuc   E h = E();
63*f4a2713aSLionel Sambuc }
64*f4a2713aSLionel Sambuc 
65*f4a2713aSLionel Sambuc namespace BaseClass {
66*f4a2713aSLionel Sambuc   template<typename T, unsigned> struct X : T {};
67*f4a2713aSLionel Sambuc   struct C { char c = 1; };
68*f4a2713aSLionel Sambuc   template<unsigned... Ns> struct Cs : X<C,Ns>... {};
69*f4a2713aSLionel Sambuc   struct N { int n = 3; };
70*f4a2713aSLionel Sambuc   struct D { double d = 4.0; };
71*f4a2713aSLionel Sambuc 
72*f4a2713aSLionel Sambuc   template<typename ...Ts>
73*f4a2713aSLionel Sambuc   struct Test : Ts... { constexpr Test() : Ts()..., n(5) {} int n; };
74*f4a2713aSLionel Sambuc 
75*f4a2713aSLionel Sambuc   using Test1 = Test<N, C, Cs<1,2>, D, X<C,1>>;
76*f4a2713aSLionel Sambuc   // CHECK: @_ZN9BaseClass2t1E = constant {{.*}} { i32 3, i8 1, i8 1, i8 1, double 4.000000e+00, i8 1, i32 5 }, align 8
77*f4a2713aSLionel Sambuc   extern constexpr Test1 t1 = Test1();
78*f4a2713aSLionel Sambuc 
79*f4a2713aSLionel Sambuc   struct DN : D, N {};
80*f4a2713aSLionel Sambuc   struct DND : DN, X<D,0> {};
81*f4a2713aSLionel Sambuc   struct DNN : DN, X<N,0> {};
82*f4a2713aSLionel Sambuc   // CHECK: @_ZN9BaseClass3dndE = constant {{.*}} { double 4.000000e+00, i32 3, double 4.000000e+00 }
83*f4a2713aSLionel Sambuc   extern constexpr DND dnd = DND();
84*f4a2713aSLionel Sambuc   // Note, N subobject is laid out in DN subobject's tail padding.
85*f4a2713aSLionel Sambuc   // CHECK: @_ZN9BaseClass3dnnE = constant {{.*}} { double 4.000000e+00, i32 3, i32 3 }
86*f4a2713aSLionel Sambuc   extern constexpr DNN dnn = DNN();
87*f4a2713aSLionel Sambuc 
88*f4a2713aSLionel Sambuc   struct E {};
89*f4a2713aSLionel Sambuc   struct Test2 : X<E,0>, X<E,1>, X<E,2>, X<E,3> {};
90*f4a2713aSLionel Sambuc   // CHECK: @_ZN9BaseClass2t2E = constant {{.*}} undef
91*f4a2713aSLionel Sambuc   extern constexpr Test2 t2 = Test2();
92*f4a2713aSLionel Sambuc 
93*f4a2713aSLionel Sambuc   struct __attribute((packed)) PackedD { double y = 2; };
94*f4a2713aSLionel Sambuc   struct Test3 : C, PackedD { constexpr Test3() {} };
95*f4a2713aSLionel Sambuc   // CHECK: @_ZN9BaseClass2t3E = constant <{ i8, double }> <{ i8 1, double 2.000000e+00 }>
96*f4a2713aSLionel Sambuc   extern constexpr Test3 t3 = Test3();
97*f4a2713aSLionel Sambuc }
98*f4a2713aSLionel Sambuc 
99*f4a2713aSLionel Sambuc namespace Array {
100*f4a2713aSLionel Sambuc   // CHECK: @_ZN5Array3arrE = constant [2 x i32] [i32 4, i32 0]
101*f4a2713aSLionel Sambuc   extern constexpr int arr[2] = { 4 };
102*f4a2713aSLionel Sambuc 
103*f4a2713aSLionel Sambuc   // CHECK: @_ZN5Array1cE = constant [6 x [4 x i8]] [{{.*}} c"foo\00", [4 x i8] c"a\00\00\00", [4 x i8] c"bar\00", [4 x i8] c"xyz\00", [4 x i8] c"b\00\00\00", [4 x i8] c"123\00"]
104*f4a2713aSLionel Sambuc   extern constexpr char c[6][4] = { "foo", "a", { "bar" }, { 'x', 'y', 'z' }, { "b" }, '1', '2', '3' };
105*f4a2713aSLionel Sambuc 
106*f4a2713aSLionel Sambuc   // CHECK: @_ZN5Array2ucE = constant [4 x i8] c"foo\00"
107*f4a2713aSLionel Sambuc   extern constexpr unsigned char uc[] = { "foo" };
108*f4a2713aSLionel Sambuc 
109*f4a2713aSLionel Sambuc   struct C { constexpr C() : n(5) {} int n, m = 3 * n + 1; };
110*f4a2713aSLionel Sambuc   // CHECK: @_ZN5Array5ctorsE = constant [3 x {{.*}}] [{{.*}} { i32 5, i32 16 }, {{.*}} { i32 5, i32 16 }, {{.*}} { i32 5, i32 16 }]
111*f4a2713aSLionel Sambuc   extern const C ctors[3];
112*f4a2713aSLionel Sambuc   constexpr C ctors[3];
113*f4a2713aSLionel Sambuc 
114*f4a2713aSLionel Sambuc   // CHECK: @_ZN5Array1dE = constant {{.*}} { [2 x i32] [i32 1, i32 2], [3 x i32] [i32 3, i32 4, i32 5] }
115*f4a2713aSLionel Sambuc   struct D { int n[2]; int m[3]; } extern constexpr d = { 1, 2, 3, 4, 5 };
116*f4a2713aSLionel Sambuc 
117*f4a2713aSLionel Sambuc   struct E {
118*f4a2713aSLionel Sambuc     char c[4];
119*f4a2713aSLionel Sambuc     char d[4];
120*f4a2713aSLionel Sambuc     constexpr E() : c("foo"), d("x") {}
121*f4a2713aSLionel Sambuc   };
122*f4a2713aSLionel Sambuc   // CHECK: @_ZN5Array1eE = constant {{.*}} { [4 x i8] c"foo\00", [4 x i8] c"x\00\00\00" }
123*f4a2713aSLionel Sambuc   extern constexpr E e = E();
124*f4a2713aSLionel Sambuc 
125*f4a2713aSLionel Sambuc   // PR13290
126*f4a2713aSLionel Sambuc   struct F { constexpr F() : n(4) {} int n; };
127*f4a2713aSLionel Sambuc   // CHECK: @_ZN5Array2f1E = global {{.*}} zeroinitializer
128*f4a2713aSLionel Sambuc   F f1[1][1][0] = { };
129*f4a2713aSLionel Sambuc   // CHECK: @_ZN5Array2f2E = global {{.* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4}}
130*f4a2713aSLionel Sambuc   F f2[2][2][2] = { };
131*f4a2713aSLionel Sambuc }
132*f4a2713aSLionel Sambuc 
133*f4a2713aSLionel Sambuc namespace MemberPtr {
134*f4a2713aSLionel Sambuc   struct B1 {
135*f4a2713aSLionel Sambuc     int a, b;
136*f4a2713aSLionel Sambuc     virtual void f();
137*f4a2713aSLionel Sambuc     void g();
138*f4a2713aSLionel Sambuc   };
139*f4a2713aSLionel Sambuc   struct B2 {
140*f4a2713aSLionel Sambuc     int c, d;
141*f4a2713aSLionel Sambuc     virtual void h();
142*f4a2713aSLionel Sambuc     void i();
143*f4a2713aSLionel Sambuc   };
144*f4a2713aSLionel Sambuc   struct C : B1 {
145*f4a2713aSLionel Sambuc     int e;
146*f4a2713aSLionel Sambuc     virtual void j();
147*f4a2713aSLionel Sambuc     void k();
148*f4a2713aSLionel Sambuc   };
149*f4a2713aSLionel Sambuc   struct D : C, B2 {
150*f4a2713aSLionel Sambuc     int z;
151*f4a2713aSLionel Sambuc     virtual void l();
152*f4a2713aSLionel Sambuc     void m();
153*f4a2713aSLionel Sambuc   };
154*f4a2713aSLionel Sambuc 
155*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2daE = constant i64 8
156*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2dbE = constant i64 12
157*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2dcE = constant i64 32
158*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2ddE = constant i64 36
159*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2deE = constant i64 16
160*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2dzE = constant i64 40
161*f4a2713aSLionel Sambuc   extern constexpr int (D::*da) = &B1::a;
162*f4a2713aSLionel Sambuc   extern constexpr int (D::*db) = &C::b;
163*f4a2713aSLionel Sambuc   extern constexpr int (D::*dc) = &B2::c;
164*f4a2713aSLionel Sambuc   extern constexpr int (D::*dd) = &D::d;
165*f4a2713aSLionel Sambuc   extern constexpr int (D::*de) = &C::e;
166*f4a2713aSLionel Sambuc   extern constexpr int (D::*dz) = &D::z;
167*f4a2713aSLionel Sambuc 
168*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2baE = constant i64 8
169*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2bbE = constant i64 12
170*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2bcE = constant i64 8
171*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2bdE = constant i64 12
172*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2beE = constant i64 16
173*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr3b1zE = constant i64 40
174*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr3b2zE = constant i64 16
175*f4a2713aSLionel Sambuc   extern constexpr int (B1::*ba) = (int(B1::*))&B1::a;
176*f4a2713aSLionel Sambuc   extern constexpr int (B1::*bb) = (int(B1::*))&C::b;
177*f4a2713aSLionel Sambuc   extern constexpr int (B2::*bc) = (int(B2::*))&B2::c;
178*f4a2713aSLionel Sambuc   extern constexpr int (B2::*bd) = (int(B2::*))&D::d;
179*f4a2713aSLionel Sambuc   extern constexpr int (B1::*be) = (int(B1::*))&C::e;
180*f4a2713aSLionel Sambuc   extern constexpr int (B1::*b1z) = (int(B1::*))&D::z;
181*f4a2713aSLionel Sambuc   extern constexpr int (B2::*b2z) = (int(B2::*))&D::z;
182*f4a2713aSLionel Sambuc 
183*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2dfE = constant {{.*}} { i64 1, i64 0 }
184*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2dgE = constant {{.*}} { i64 {{.*}}2B11gEv{{.*}}, i64 0 }
185*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2dhE = constant {{.*}} { i64 1, i64 24 }
186*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2diE = constant {{.*}} { i64 {{.*}}2B21iEv{{.*}}, i64 24 }
187*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2djE = constant {{.*}} { i64 9, i64 0 }
188*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2dkE = constant {{.*}} { i64 {{.*}}1C1kEv{{.*}}, i64 0 }
189*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2dlE = constant {{.*}} { i64 17, i64 0 }
190*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2dmE = constant {{.*}} { i64 {{.*}}1D1mEv{{.*}}, i64 0 }
191*f4a2713aSLionel Sambuc   extern constexpr void (D::*df)() = &C::f;
192*f4a2713aSLionel Sambuc   extern constexpr void (D::*dg)() = &B1::g;
193*f4a2713aSLionel Sambuc   extern constexpr void (D::*dh)() = &B2::h;
194*f4a2713aSLionel Sambuc   extern constexpr void (D::*di)() = &D::i;
195*f4a2713aSLionel Sambuc   extern constexpr void (D::*dj)() = &C::j;
196*f4a2713aSLionel Sambuc   extern constexpr void (D::*dk)() = &C::k;
197*f4a2713aSLionel Sambuc   extern constexpr void (D::*dl)() = &D::l;
198*f4a2713aSLionel Sambuc   extern constexpr void (D::*dm)() = &D::m;
199*f4a2713aSLionel Sambuc 
200*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2bfE = constant {{.*}} { i64 1, i64 0 }
201*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2bgE = constant {{.*}} { i64 {{.*}}2B11gEv{{.*}}, i64 0 }
202*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2bhE = constant {{.*}} { i64 1, i64 0 }
203*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2biE = constant {{.*}} { i64 {{.*}}2B21iEv{{.*}}, i64 0 }
204*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2bjE = constant {{.*}} { i64 9, i64 0 }
205*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr2bkE = constant {{.*}} { i64 {{.*}}1C1kEv{{.*}}, i64 0 }
206*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr3b1lE = constant {{.*}} { i64 17, i64 0 }
207*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr3b1mE = constant {{.*}} { i64 {{.*}}1D1mEv{{.*}}, i64 0 }
208*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr3b2lE = constant {{.*}} { i64 17, i64 -24 }
209*f4a2713aSLionel Sambuc   // CHECK: @_ZN9MemberPtr3b2mE = constant {{.*}} { i64 {{.*}}1D1mEv{{.*}}, i64 -24 }
210*f4a2713aSLionel Sambuc   extern constexpr void (B1::*bf)()  = (void(B1::*)())&C::f;
211*f4a2713aSLionel Sambuc   extern constexpr void (B1::*bg)()  = (void(B1::*)())&B1::g;
212*f4a2713aSLionel Sambuc   extern constexpr void (B2::*bh)()  = (void(B2::*)())&B2::h;
213*f4a2713aSLionel Sambuc   extern constexpr void (B2::*bi)()  = (void(B2::*)())&D::i;
214*f4a2713aSLionel Sambuc   extern constexpr void (B1::*bj)()  = (void(B1::*)())&C::j;
215*f4a2713aSLionel Sambuc   extern constexpr void (B1::*bk)()  = (void(B1::*)())&C::k;
216*f4a2713aSLionel Sambuc   extern constexpr void (B1::*b1l)() = (void(B1::*)())&D::l;
217*f4a2713aSLionel Sambuc   extern constexpr void (B1::*b1m)() = (void(B1::*)())&D::m;
218*f4a2713aSLionel Sambuc   extern constexpr void (B2::*b2l)() = (void(B2::*)())&D::l;
219*f4a2713aSLionel Sambuc   extern constexpr void (B2::*b2m)() = (void(B2::*)())&D::m;
220*f4a2713aSLionel Sambuc }
221*f4a2713aSLionel Sambuc 
222*f4a2713aSLionel Sambuc namespace LiteralReference {
223*f4a2713aSLionel Sambuc   struct Lit {
224*f4a2713aSLionel Sambuc     constexpr Lit() : n(5) {}
225*f4a2713aSLionel Sambuc     int n;
226*f4a2713aSLionel Sambuc   };
227*f4a2713aSLionel Sambuc 
228*f4a2713aSLionel Sambuc   // This creates a non-const temporary and binds a reference to it.
229*f4a2713aSLionel Sambuc   // CHECK: @[[TEMP:.*]] = private global {{.*}} { i32 5 }, align 4
230*f4a2713aSLionel Sambuc   // CHECK: @_ZN16LiteralReference3litE = constant {{.*}} @[[TEMP]], align 8
231*f4a2713aSLionel Sambuc   const Lit &lit = Lit();
232*f4a2713aSLionel Sambuc 
233*f4a2713aSLionel Sambuc   // This creates a const temporary as part of the reference initialization.
234*f4a2713aSLionel Sambuc   // CHECK: @[[TEMP:.*]] = private constant {{.*}} { i32 5 }, align 4
235*f4a2713aSLionel Sambuc   // CHECK: @_ZN16LiteralReference4lit2E = constant {{.*}} @[[TEMP]], align 8
236*f4a2713aSLionel Sambuc   const Lit &lit2 = {};
237*f4a2713aSLionel Sambuc 
238*f4a2713aSLionel Sambuc   struct A { int &&r1; const int &&r2; };
239*f4a2713aSLionel Sambuc   struct B { A &&a1; const A &&a2; };
240*f4a2713aSLionel Sambuc   B b = { { 0, 1 }, { 2, 3 } };
241*f4a2713aSLionel Sambuc   // CHECK: @[[TEMP0:.*]] = private global i32 0, align 4
242*f4a2713aSLionel Sambuc   // CHECK: @[[TEMP1:.*]] = private constant i32 1, align 4
243*f4a2713aSLionel Sambuc   // CHECK: @[[TEMPA1:.*]] = private global {{.*}} { i32* @[[TEMP0]], i32* @[[TEMP1]] }, align 8
244*f4a2713aSLionel Sambuc   // CHECK: @[[TEMP2:.*]] = private global i32 2, align 4
245*f4a2713aSLionel Sambuc   // CHECK: @[[TEMP3:.*]] = private constant i32 3, align 4
246*f4a2713aSLionel Sambuc   // CHECK: @[[TEMPA2:.*]] = private constant {{.*}} { i32* @[[TEMP2]], i32* @[[TEMP3]] }, align 8
247*f4a2713aSLionel Sambuc   // CHECK: @_ZN16LiteralReference1bE = global {{.*}} { {{.*}}* @[[TEMPA1]], {{.*}}* @[[TEMPA2]] }, align 8
248*f4a2713aSLionel Sambuc 
249*f4a2713aSLionel Sambuc   struct Subobj {
250*f4a2713aSLionel Sambuc     int a, b, c;
251*f4a2713aSLionel Sambuc   };
252*f4a2713aSLionel Sambuc   // CHECK: @[[TEMP:.*]] = private global {{.*}} { i32 1, i32 2, i32 3 }, align 4
253*f4a2713aSLionel Sambuc   // CHECK: @_ZN16LiteralReference2soE = constant {{.*}} (i8* getelementptr {{.*}} @[[TEMP]]{{.*}}, i64 4)
254*f4a2713aSLionel Sambuc   constexpr int &&so = Subobj{ 1, 2, 3 }.b;
255*f4a2713aSLionel Sambuc 
256*f4a2713aSLionel Sambuc   struct Dummy { int padding; };
257*f4a2713aSLionel Sambuc   struct Derived : Dummy, Subobj {
258*f4a2713aSLionel Sambuc     constexpr Derived() : Dummy{200}, Subobj{4, 5, 6} {}
259*f4a2713aSLionel Sambuc   };
260*f4a2713aSLionel Sambuc   using ConstDerived = const Derived;
261*f4a2713aSLionel Sambuc   // CHECK: @[[TEMPCOMMA:.*]] = private constant {{.*}} { i32 200, i32 4, i32 5, i32 6 }
262*f4a2713aSLionel Sambuc   // CHECK: @_ZN16LiteralReference5commaE = constant {{.*}} getelementptr {{.*}} @[[TEMPCOMMA]]{{.*}}, i64 8)
263*f4a2713aSLionel Sambuc   constexpr const int &comma = (1, (2, ConstDerived{}).b);
264*f4a2713aSLionel Sambuc 
265*f4a2713aSLionel Sambuc   // CHECK: @[[TEMPDERIVED:.*]] = private global {{.*}} { i32 200, i32 4, i32 5, i32 6 }
266*f4a2713aSLionel Sambuc   // CHECK: @_ZN16LiteralReference4baseE = constant {{.*}} getelementptr {{.*}} @[[TEMPDERIVED]]{{.*}}, i64 4)
267*f4a2713aSLionel Sambuc   constexpr Subobj &&base = Derived{};
268*f4a2713aSLionel Sambuc 
269*f4a2713aSLionel Sambuc   // CHECK: @_ZN16LiteralReference7derivedE = constant {{.*}} @[[TEMPDERIVED]]
270*f4a2713aSLionel Sambuc   constexpr Derived &derived = static_cast<Derived&>(base);
271*f4a2713aSLionel Sambuc }
272*f4a2713aSLionel Sambuc 
273*f4a2713aSLionel Sambuc namespace NonLiteralConstexpr {
274*f4a2713aSLionel Sambuc   constexpr int factorial(int n) {
275*f4a2713aSLionel Sambuc     return n ? factorial(n-1) * n : 1;
276*f4a2713aSLionel Sambuc   }
277*f4a2713aSLionel Sambuc   extern void f(int *p);
278*f4a2713aSLionel Sambuc 
279*f4a2713aSLionel Sambuc   struct NonTrivialDtor {
280*f4a2713aSLionel Sambuc     constexpr NonTrivialDtor() : n(factorial(5)), p(&n) {}
281*f4a2713aSLionel Sambuc     ~NonTrivialDtor() {
282*f4a2713aSLionel Sambuc       f(p);
283*f4a2713aSLionel Sambuc     }
284*f4a2713aSLionel Sambuc 
285*f4a2713aSLionel Sambuc     int n;
286*f4a2713aSLionel Sambuc     int *p;
287*f4a2713aSLionel Sambuc   };
288*f4a2713aSLionel Sambuc   static_assert(!__is_literal(NonTrivialDtor), "");
289*f4a2713aSLionel Sambuc   // CHECK: @_ZN19NonLiteralConstexpr3ntdE = global {{.*}} { i32 120, i32* getelementptr
290*f4a2713aSLionel Sambuc   NonTrivialDtor ntd;
291*f4a2713aSLionel Sambuc 
292*f4a2713aSLionel Sambuc   struct VolatileMember {
293*f4a2713aSLionel Sambuc     constexpr VolatileMember() : n(5) {}
294*f4a2713aSLionel Sambuc     volatile int n;
295*f4a2713aSLionel Sambuc   };
296*f4a2713aSLionel Sambuc   static_assert(!__is_literal(VolatileMember), "");
297*f4a2713aSLionel Sambuc   // CHECK: @_ZN19NonLiteralConstexpr2vmE = global {{.*}} { i32 5 }
298*f4a2713aSLionel Sambuc   VolatileMember vm;
299*f4a2713aSLionel Sambuc 
300*f4a2713aSLionel Sambuc   struct Both {
301*f4a2713aSLionel Sambuc     constexpr Both() : n(10) {}
302*f4a2713aSLionel Sambuc     ~Both();
303*f4a2713aSLionel Sambuc     volatile int n;
304*f4a2713aSLionel Sambuc   };
305*f4a2713aSLionel Sambuc   // CHECK: @_ZN19NonLiteralConstexpr1bE = global {{.*}} { i32 10 }
306*f4a2713aSLionel Sambuc   Both b;
307*f4a2713aSLionel Sambuc 
308*f4a2713aSLionel Sambuc   void StaticVars() {
309*f4a2713aSLionel Sambuc     // CHECK: @_ZZN19NonLiteralConstexpr10StaticVarsEvE3ntd = {{.*}} { i32 120, i32* getelementptr {{.*}}
310*f4a2713aSLionel Sambuc     // CHECK: @_ZGVZN19NonLiteralConstexpr10StaticVarsEvE3ntd =
311*f4a2713aSLionel Sambuc     static NonTrivialDtor ntd;
312*f4a2713aSLionel Sambuc     // CHECK: @_ZZN19NonLiteralConstexpr10StaticVarsEvE2vm = {{.*}} { i32 5 }
313*f4a2713aSLionel Sambuc     // CHECK-NOT: @_ZGVZN19NonLiteralConstexpr10StaticVarsEvE2vm =
314*f4a2713aSLionel Sambuc     static VolatileMember vm;
315*f4a2713aSLionel Sambuc     // CHECK: @_ZZN19NonLiteralConstexpr10StaticVarsEvE1b = {{.*}} { i32 10 }
316*f4a2713aSLionel Sambuc     // CHECK: @_ZGVZN19NonLiteralConstexpr10StaticVarsEvE1b =
317*f4a2713aSLionel Sambuc     static Both b;
318*f4a2713aSLionel Sambuc   }
319*f4a2713aSLionel Sambuc }
320*f4a2713aSLionel Sambuc 
321*f4a2713aSLionel Sambuc // PR12067
322*f4a2713aSLionel Sambuc namespace VirtualMembers {
323*f4a2713aSLionel Sambuc   struct A {
324*f4a2713aSLionel Sambuc     constexpr A(double d) : d(d) {}
325*f4a2713aSLionel Sambuc     virtual void f();
326*f4a2713aSLionel Sambuc     double d;
327*f4a2713aSLionel Sambuc   };
328*f4a2713aSLionel Sambuc   struct B : A {
329*f4a2713aSLionel Sambuc     constexpr B() : A(2.0), c{'h', 'e', 'l', 'l', 'o'} {}
330*f4a2713aSLionel Sambuc     constexpr B(int n) : A(n), c{'w', 'o', 'r', 'l', 'd'} {}
331*f4a2713aSLionel Sambuc     virtual void g();
332*f4a2713aSLionel Sambuc     char c[5];
333*f4a2713aSLionel Sambuc   };
334*f4a2713aSLionel Sambuc   struct C {
335*f4a2713aSLionel Sambuc     constexpr C() : n(64) {}
336*f4a2713aSLionel Sambuc     int n;
337*f4a2713aSLionel Sambuc   };
338*f4a2713aSLionel Sambuc   struct D : C, A, B {
339*f4a2713aSLionel Sambuc     constexpr D() : A(1.0), B(), s(5) {}
340*f4a2713aSLionel Sambuc     short s;
341*f4a2713aSLionel Sambuc   };
342*f4a2713aSLionel Sambuc   struct E : D, B {
343*f4a2713aSLionel Sambuc     constexpr E() : B(3), c{'b','y','e'} {}
344*f4a2713aSLionel Sambuc     char c[3];
345*f4a2713aSLionel Sambuc   };
346*f4a2713aSLionel Sambuc 
347*f4a2713aSLionel Sambuc   // CHECK: @_ZN14VirtualMembers1eE = global { i8**, double, i32, i8**, double, [5 x i8], i16, i8**, double, [5 x i8], [3 x i8] } { i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 2), double 1.000000e+00, i32 64, i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 5), double 2.000000e+00, [5 x i8] c"hello", i16 5, i8** getelementptr inbounds ([11 x i8*]* @_ZTVN14VirtualMembers1EE, i64 0, i64 9), double 3.000000e+00, [5 x i8] c"world", [3 x i8] c"bye" }
348*f4a2713aSLionel Sambuc   E e;
349*f4a2713aSLionel Sambuc 
350*f4a2713aSLionel Sambuc   struct nsMemoryImpl {
351*f4a2713aSLionel Sambuc     virtual void f();
352*f4a2713aSLionel Sambuc   };
353*f4a2713aSLionel Sambuc   // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global { i8** } { i8** getelementptr inbounds ([3 x i8*]* @_ZTVN14VirtualMembers12nsMemoryImplE, i64 0, i64 2) }
354*f4a2713aSLionel Sambuc   static nsMemoryImpl sGlobalMemory;
355*f4a2713aSLionel Sambuc }
356*f4a2713aSLionel Sambuc 
357*f4a2713aSLionel Sambuc namespace PR13273 {
358*f4a2713aSLionel Sambuc   struct U {
359*f4a2713aSLionel Sambuc     int t;
360*f4a2713aSLionel Sambuc     U() = default;
361*f4a2713aSLionel Sambuc   };
362*f4a2713aSLionel Sambuc 
363*f4a2713aSLionel Sambuc   struct S : U {
364*f4a2713aSLionel Sambuc     S() = default;
365*f4a2713aSLionel Sambuc   };
366*f4a2713aSLionel Sambuc 
367*f4a2713aSLionel Sambuc   // CHECK: @_ZN7PR132731sE = {{.*}} zeroinitializer
368*f4a2713aSLionel Sambuc   extern const S s {};
369*f4a2713aSLionel Sambuc }
370*f4a2713aSLionel Sambuc 
371*f4a2713aSLionel Sambuc namespace ArrayTemporary {
372*f4a2713aSLionel Sambuc   struct A { const int (&x)[3]; };
373*f4a2713aSLionel Sambuc   struct B { const A (&x)[2]; };
374*f4a2713aSLionel Sambuc   // CHECK: @[[A1:_ZGRN14ArrayTemporary1bE.*]] = private constant [3 x i32] [i32 1, i32 2, i32 3]
375*f4a2713aSLionel Sambuc   // CHECK: @[[A2:_ZGRN14ArrayTemporary1bE.*]] = private constant [3 x i32] [i32 4, i32 5, i32 6]
376*f4a2713aSLionel Sambuc   // CHECK: @[[ARR:_ZGRN14ArrayTemporary1bE.*]] = private constant [2 x {{.*}}] [{{.*}} { [3 x i32]* @[[A1]] }, {{.*}} { [3 x i32]* @[[A2]] }]
377*f4a2713aSLionel Sambuc   // CHECK: @[[B:_ZGRN14ArrayTemporary1bE.*]] = private global {{.*}} { [2 x {{.*}}]* @[[ARR]] }
378*f4a2713aSLionel Sambuc   // CHECK: @_ZN14ArrayTemporary1bE = constant {{.*}}* @[[B]]
379*f4a2713aSLionel Sambuc   B &&b = { { { { 1, 2, 3 } }, { { 4, 5, 6 } } } };
380*f4a2713aSLionel Sambuc }
381*f4a2713aSLionel Sambuc 
382*f4a2713aSLionel Sambuc namespace UnemittedTemporaryDecl {
383*f4a2713aSLionel Sambuc   constexpr int &&ref = 0;
384*f4a2713aSLionel Sambuc   extern constexpr int &ref2 = ref;
385*f4a2713aSLionel Sambuc   // CHECK: @_ZGRN22UnemittedTemporaryDecl3refE = private global i32 0
386*f4a2713aSLionel Sambuc 
387*f4a2713aSLionel Sambuc   // FIXME: This declaration should not be emitted -- it isn't odr-used.
388*f4a2713aSLionel Sambuc   // CHECK: @_ZN22UnemittedTemporaryDecl3refE
389*f4a2713aSLionel Sambuc 
390*f4a2713aSLionel Sambuc   // CHECK: @_ZN22UnemittedTemporaryDecl4ref2E = constant i32* @_ZGRN22UnemittedTemporaryDecl3refE
391*f4a2713aSLionel Sambuc }
392*f4a2713aSLionel Sambuc 
393*f4a2713aSLionel Sambuc // CHECK: @_ZZN12LocalVarInit3aggEvE1a = internal constant {{.*}} i32 101
394*f4a2713aSLionel Sambuc // CHECK: @_ZZN12LocalVarInit4ctorEvE1a = internal constant {{.*}} i32 102
395*f4a2713aSLionel Sambuc // CHECK: @_ZZN12LocalVarInit8mutable_EvE1a = private unnamed_addr constant {{.*}} i32 103
396*f4a2713aSLionel Sambuc 
397*f4a2713aSLionel Sambuc // Constant initialization tests go before this point,
398*f4a2713aSLionel Sambuc // dynamic initialization tests go after.
399*f4a2713aSLionel Sambuc 
400*f4a2713aSLionel Sambuc // We must emit a constant initializer for NonLiteralConstexpr::ntd, but also
401*f4a2713aSLionel Sambuc // emit an initializer to register its destructor.
402*f4a2713aSLionel Sambuc // CHECK: define {{.*}}cxx_global_var_init{{.*}}
403*f4a2713aSLionel Sambuc // CHECK-NOT: NonLiteralConstexpr
404*f4a2713aSLionel Sambuc // CHECK: call {{.*}}cxa_atexit{{.*}} @_ZN19NonLiteralConstexpr14NonTrivialDtorD1Ev {{.*}} @_ZN19NonLiteralConstexpr3ntdE
405*f4a2713aSLionel Sambuc // CHECK-NEXT: ret void
406*f4a2713aSLionel Sambuc 
407*f4a2713aSLionel Sambuc // We don't need to emit any dynamic initialization for NonLiteralConstexpr::vm.
408*f4a2713aSLionel Sambuc // CHECK-NOT: NonLiteralConstexpr2vm
409*f4a2713aSLionel Sambuc 
410*f4a2713aSLionel Sambuc // We must emit a constant initializer for NonLiteralConstexpr::b, but also
411*f4a2713aSLionel Sambuc // emit an initializer to register its destructor.
412*f4a2713aSLionel Sambuc // CHECK: define {{.*}}cxx_global_var_init{{.*}}
413*f4a2713aSLionel Sambuc // CHECK-NOT: NonLiteralConstexpr
414*f4a2713aSLionel Sambuc // CHECK: call {{.*}}cxa_atexit{{.*}} @_ZN19NonLiteralConstexpr4BothD1Ev {{.*}} @_ZN19NonLiteralConstexpr1bE
415*f4a2713aSLionel Sambuc // CHECK-NEXT: ret void
416*f4a2713aSLionel Sambuc 
417*f4a2713aSLionel Sambuc // CHECK: define {{.*}}NonLiteralConstexpr10StaticVars
418*f4a2713aSLionel Sambuc // CHECK-NOT: }
419*f4a2713aSLionel Sambuc // CHECK: call {{.*}}cxa_atexit{{.*}}@_ZN19NonLiteralConstexpr14NonTrivialDtorD1Ev
420*f4a2713aSLionel Sambuc // CHECK-NOT: }
421*f4a2713aSLionel Sambuc // CHECK: call {{.*}}cxa_atexit{{.*}}@_ZN19NonLiteralConstexpr4BothD1Ev
422*f4a2713aSLionel Sambuc 
423*f4a2713aSLionel Sambuc // PR12848: Don't emit dynamic initializers for local constexpr variables.
424*f4a2713aSLionel Sambuc namespace LocalVarInit {
425*f4a2713aSLionel Sambuc   constexpr int f(int n) { return n; }
426*f4a2713aSLionel Sambuc   struct Agg { int k; };
427*f4a2713aSLionel Sambuc   struct Ctor { constexpr Ctor(int n) : k(n) {} int k; };
428*f4a2713aSLionel Sambuc   struct Mutable { constexpr Mutable(int n) : k(n) {} mutable int k; };
429*f4a2713aSLionel Sambuc 
430*f4a2713aSLionel Sambuc   // CHECK: define {{.*}} @_ZN12LocalVarInit6scalarEv
431*f4a2713aSLionel Sambuc   // CHECK-NOT: call
432*f4a2713aSLionel Sambuc   // CHECK: store i32 100,
433*f4a2713aSLionel Sambuc   // CHECK-NOT: call
434*f4a2713aSLionel Sambuc   // CHECK: ret i32 100
435*f4a2713aSLionel Sambuc   int scalar() { constexpr int a = { f(100) }; return a; }
436*f4a2713aSLionel Sambuc 
437*f4a2713aSLionel Sambuc   // CHECK: define {{.*}} @_ZN12LocalVarInit3aggEv
438*f4a2713aSLionel Sambuc   // CHECK-NOT: call
439*f4a2713aSLionel Sambuc   // CHECK: ret i32 101
440*f4a2713aSLionel Sambuc   int agg() { constexpr Agg a = { f(101) }; return a.k; }
441*f4a2713aSLionel Sambuc 
442*f4a2713aSLionel Sambuc   // CHECK: define {{.*}} @_ZN12LocalVarInit4ctorEv
443*f4a2713aSLionel Sambuc   // CHECK-NOT: call
444*f4a2713aSLionel Sambuc   // CHECK: ret i32 102
445*f4a2713aSLionel Sambuc   int ctor() { constexpr Ctor a = { f(102) }; return a.k; }
446*f4a2713aSLionel Sambuc 
447*f4a2713aSLionel Sambuc   // CHECK: define {{.*}} @_ZN12LocalVarInit8mutable_Ev
448*f4a2713aSLionel Sambuc   // CHECK-NOT: call
449*f4a2713aSLionel Sambuc   // CHECK: call {{.*}}memcpy{{.*}} @_ZZN12LocalVarInit8mutable_EvE1a
450*f4a2713aSLionel Sambuc   // CHECK-NOT: call
451*f4a2713aSLionel Sambuc   // Can't fold return value due to 'mutable'.
452*f4a2713aSLionel Sambuc   // CHECK-NOT: ret i32 103
453*f4a2713aSLionel Sambuc   // CHECK: }
454*f4a2713aSLionel Sambuc   int mutable_() { constexpr Mutable a = { f(103) }; return a.k; }
455*f4a2713aSLionel Sambuc }
456*f4a2713aSLionel Sambuc 
457*f4a2713aSLionel Sambuc namespace CrossFuncLabelDiff {
458*f4a2713aSLionel Sambuc   // Make sure we refuse to constant-fold the variable b.
459*f4a2713aSLionel Sambuc   constexpr long a(bool x) { return x ? 0 : (long)&&lbl + (0 && ({lbl: 0;})); }
460*f4a2713aSLionel Sambuc   void test() { static long b = (long)&&lbl - a(false); lbl: return; }
461*f4a2713aSLionel Sambuc   // CHECK: sub nsw i64 ptrtoint (i8* blockaddress(@_ZN18CrossFuncLabelDiff4testEv, {{.*}}) to i64),
462*f4a2713aSLionel Sambuc   // CHECK: store i64 {{.*}}, i64* @_ZZN18CrossFuncLabelDiff4testEvE1b, align 8
463*f4a2713aSLionel Sambuc }
464*f4a2713aSLionel Sambuc 
465*f4a2713aSLionel Sambuc // PR12012
466*f4a2713aSLionel Sambuc namespace VirtualBase {
467*f4a2713aSLionel Sambuc   struct B {};
468*f4a2713aSLionel Sambuc   struct D : virtual B {};
469*f4a2713aSLionel Sambuc   D d;
470*f4a2713aSLionel Sambuc   // CHECK: call {{.*}}@_ZN11VirtualBase1DC1Ev
471*f4a2713aSLionel Sambuc 
472*f4a2713aSLionel Sambuc   template<typename T> struct X : T {
473*f4a2713aSLionel Sambuc     constexpr X() : T() {}
474*f4a2713aSLionel Sambuc   };
475*f4a2713aSLionel Sambuc   X<D> x;
476*f4a2713aSLionel Sambuc   // CHECK: call {{.*}}@_ZN11VirtualBase1XINS_1DEEC1Ev
477*f4a2713aSLionel Sambuc }
478*f4a2713aSLionel Sambuc 
479*f4a2713aSLionel Sambuc // PR12145
480*f4a2713aSLionel Sambuc namespace Unreferenced {
481*f4a2713aSLionel Sambuc   int n;
482*f4a2713aSLionel Sambuc   constexpr int *p = &n;
483*f4a2713aSLionel Sambuc   // We must not emit a load of 'p' here, since it's not odr-used.
484*f4a2713aSLionel Sambuc   int q = *p;
485*f4a2713aSLionel Sambuc   // CHECK-NOT: _ZN12Unreferenced1pE
486*f4a2713aSLionel Sambuc   // CHECK: = load i32* @_ZN12Unreferenced1nE
487*f4a2713aSLionel Sambuc   // CHECK-NEXT: store i32 {{.*}}, i32* @_ZN12Unreferenced1qE
488*f4a2713aSLionel Sambuc   // CHECK-NOT: _ZN12Unreferenced1pE
489*f4a2713aSLionel Sambuc 
490*f4a2713aSLionel Sambuc   // Technically, we are not required to substitute variables of reference types
491*f4a2713aSLionel Sambuc   // initialized by constant expressions, because the special case for odr-use
492*f4a2713aSLionel Sambuc   // of variables in [basic.def.odr]p2 only applies to objects. But we do so
493*f4a2713aSLionel Sambuc   // anyway.
494*f4a2713aSLionel Sambuc 
495*f4a2713aSLionel Sambuc   constexpr int &r = n;
496*f4a2713aSLionel Sambuc   // CHECK-NOT: _ZN12Unreferenced1rE
497*f4a2713aSLionel Sambuc   int s = r;
498*f4a2713aSLionel Sambuc 
499*f4a2713aSLionel Sambuc   const int t = 1;
500*f4a2713aSLionel Sambuc   const int &rt = t;
501*f4a2713aSLionel Sambuc   int f(int);
502*f4a2713aSLionel Sambuc   int u = f(rt);
503*f4a2713aSLionel Sambuc   // CHECK: call i32 @_ZN12Unreferenced1fEi(i32 1)
504*f4a2713aSLionel Sambuc }
505*f4a2713aSLionel Sambuc 
506*f4a2713aSLionel Sambuc namespace InitFromConst {
507*f4a2713aSLionel Sambuc   template<typename T> void consume(T);
508*f4a2713aSLionel Sambuc 
509*f4a2713aSLionel Sambuc   const bool b = true;
510*f4a2713aSLionel Sambuc   const int n = 5;
511*f4a2713aSLionel Sambuc   constexpr double d = 4.3;
512*f4a2713aSLionel Sambuc 
513*f4a2713aSLionel Sambuc   struct S { int n = 7; S *p = 0; };
514*f4a2713aSLionel Sambuc   constexpr S s = S();
515*f4a2713aSLionel Sambuc   const S &r = s;
516*f4a2713aSLionel Sambuc   constexpr const S *p = &r;
517*f4a2713aSLionel Sambuc   constexpr int S::*mp = &S::n;
518*f4a2713aSLionel Sambuc   constexpr int a[3] = { 1, 4, 9 };
519*f4a2713aSLionel Sambuc 
520*f4a2713aSLionel Sambuc   void test() {
521*f4a2713aSLionel Sambuc     // CHECK: call void @_ZN13InitFromConst7consumeIbEEvT_(i1 zeroext true)
522*f4a2713aSLionel Sambuc     consume(b);
523*f4a2713aSLionel Sambuc 
524*f4a2713aSLionel Sambuc     // CHECK: call void @_ZN13InitFromConst7consumeIiEEvT_(i32 5)
525*f4a2713aSLionel Sambuc     consume(n);
526*f4a2713aSLionel Sambuc 
527*f4a2713aSLionel Sambuc     // CHECK: call void @_ZN13InitFromConst7consumeIdEEvT_(double 4.300000e+00)
528*f4a2713aSLionel Sambuc     consume(d);
529*f4a2713aSLionel Sambuc 
530*f4a2713aSLionel Sambuc     // CHECK: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
531*f4a2713aSLionel Sambuc     consume<const S&>(s);
532*f4a2713aSLionel Sambuc 
533*f4a2713aSLionel Sambuc     // CHECK: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
534*f4a2713aSLionel Sambuc     consume<const S&>(r);
535*f4a2713aSLionel Sambuc 
536*f4a2713aSLionel Sambuc     // CHECK: call void @_ZN13InitFromConst7consumeIPKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
537*f4a2713aSLionel Sambuc     consume(p);
538*f4a2713aSLionel Sambuc 
539*f4a2713aSLionel Sambuc     // CHECK: call void @_ZN13InitFromConst7consumeIMNS_1SEiEEvT_(i64 0)
540*f4a2713aSLionel Sambuc     consume(mp);
541*f4a2713aSLionel Sambuc 
542*f4a2713aSLionel Sambuc     // CHECK: call void @_ZN13InitFromConst7consumeIPKiEEvT_(i32* getelementptr inbounds ([3 x i32]* @_ZN13InitFromConstL1aE, i32 0, i32 0))
543*f4a2713aSLionel Sambuc     consume(a);
544*f4a2713aSLionel Sambuc   }
545*f4a2713aSLionel Sambuc }
546*f4a2713aSLionel Sambuc 
547*f4a2713aSLionel Sambuc namespace Null {
548*f4a2713aSLionel Sambuc   decltype(nullptr) null();
549*f4a2713aSLionel Sambuc   // CHECK: call {{.*}} @_ZN4Null4nullEv(
550*f4a2713aSLionel Sambuc   int *p = null();
551*f4a2713aSLionel Sambuc   struct S {};
552*f4a2713aSLionel Sambuc   // CHECK: call {{.*}} @_ZN4Null4nullEv(
553*f4a2713aSLionel Sambuc   int S::*q = null();
554*f4a2713aSLionel Sambuc }
555