blob: 833adba8bae7fae5d99e9e2a09fa6a8ecac9d006 [file] [log] [blame]
Eli Friedman5930a4c2012-01-05 23:59:40 +00001// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin -emit-llvm -o - %s -std=c++11 | FileCheck %s
2
Richard Smith2d6a5672012-01-14 04:30:29 +00003// FIXME: The padding in all these objects should be zero-initialized.
4namespace StructUnion {
5 struct A {
6 int n;
7 double d;
8 union U {
9 constexpr U(int x) : x(x) {}
10 constexpr U(const char *y) : y(y) {}
11 int x;
12 const char *y;
13 } u;
14
15 constexpr A(int n, double d, int x) : n(n), d(d), u(x) {}
16 constexpr A(int n, double d, const char *y) : n(n), d(d), u(y) {}
17 };
18
Richard Smithe15c7122012-02-17 04:54:50 +000019 // CHECK: @_ZN11StructUnion1aE = constant {{.*}} { i32 1, double 2.000000e+00, {{.*}} { i32 3, [4 x i8] undef } }
Richard Smith2d6a5672012-01-14 04:30:29 +000020 extern constexpr A a(1, 2.0, 3);
21
Richard Smithe15c7122012-02-17 04:54:50 +000022 // CHECK: @_ZN11StructUnion1bE = constant {{.*}} { i32 4, double 5.000000e+00, {{.*}} { i8* getelementptr inbounds ([6 x i8]* @{{.*}}, i32 0, i32 0) } }
Richard Smith2d6a5672012-01-14 04:30:29 +000023 extern constexpr A b(4, 5, "hello");
24
25 struct B {
26 int n;
27 };
28
29 // CHECK: @_ZN11StructUnion1cE = global {{.*}} zeroinitializer
30 // CHECK: @_ZN11StructUnion2c2E = global {{.*}} zeroinitializer
31 B c;
32 B c2 = B();
33
34 // CHECK: @_ZN11StructUnion1dE = global {{.*}} zeroinitializer
35 B d[10];
36
37 struct C {
38 constexpr C() : c(0) {}
39 int c;
40 };
41
42 // CHECK: @_ZN11StructUnion1eE = global {{.*}} zeroinitializer
43 C e[10];
44
45 struct D {
46 constexpr D() : d(5) {}
47 int d;
48 };
49
50 // CHECK: @_ZN11StructUnion1fE = global {{.*}} { i32 5 }
51 D f;
Richard Smithd079abf2012-05-07 01:07:30 +000052
53 union E {
54 int a;
55 void *b = &f;
56 };
57
58 // CHECK: @_ZN11StructUnion1gE = global {{.*}} @_ZN11StructUnion1fE
59 E g;
60
61 // CHECK: @_ZN11StructUnion1hE = global {{.*}} @_ZN11StructUnion1fE
62 E h = E();
Richard Smith2d6a5672012-01-14 04:30:29 +000063}
64
65namespace BaseClass {
66 template<typename T, unsigned> struct X : T {};
67 struct C { char c = 1; };
68 template<unsigned... Ns> struct Cs : X<C,Ns>... {};
69 struct N { int n = 3; };
70 struct D { double d = 4.0; };
71
72 template<typename ...Ts>
73 struct Test : Ts... { constexpr Test() : Ts()..., n(5) {} int n; };
74
75 using Test1 = Test<N, C, Cs<1,2>, D, X<C,1>>;
Richard Smithe15c7122012-02-17 04:54:50 +000076 // CHECK: @_ZN9BaseClass2t1E = constant {{.*}} { i32 3, i8 1, i8 1, i8 1, double 4.000000e+00, i8 1, i32 5 }, align 8
Richard Smith2d6a5672012-01-14 04:30:29 +000077 extern constexpr Test1 t1 = Test1();
78
79 struct DN : D, N {};
80 struct DND : DN, X<D,0> {};
81 struct DNN : DN, X<N,0> {};
Richard Smithe15c7122012-02-17 04:54:50 +000082 // CHECK: @_ZN9BaseClass3dndE = constant {{.*}} { double 4.000000e+00, i32 3, double 4.000000e+00 }
Richard Smith2d6a5672012-01-14 04:30:29 +000083 extern constexpr DND dnd = DND();
84 // Note, N subobject is laid out in DN subobject's tail padding.
Richard Smithe15c7122012-02-17 04:54:50 +000085 // CHECK: @_ZN9BaseClass3dnnE = constant {{.*}} { double 4.000000e+00, i32 3, i32 3 }
Richard Smith2d6a5672012-01-14 04:30:29 +000086 extern constexpr DNN dnn = DNN();
87
88 struct E {};
89 struct Test2 : X<E,0>, X<E,1>, X<E,2>, X<E,3> {};
Richard Smithe15c7122012-02-17 04:54:50 +000090 // CHECK: @_ZN9BaseClass2t2E = constant {{.*}} undef
Richard Smith2d6a5672012-01-14 04:30:29 +000091 extern constexpr Test2 t2 = Test2();
Eli Friedman5fe61c62012-03-30 03:55:31 +000092
93 struct __attribute((packed)) PackedD { double y = 2; };
94 struct Test3 : C, PackedD { constexpr Test3() {} };
95 // CHECK: @_ZN9BaseClass2t3E = constant <{ i8, double }> <{ i8 1, double 2.000000e+00 }>
96 extern constexpr Test3 t3 = Test3();
Richard Smith2d6a5672012-01-14 04:30:29 +000097}
98
99namespace Array {
100 // CHECK: @_ZN5Array3arrE = constant [2 x i32] [i32 4, i32 0]
101 extern constexpr int arr[2] = { 4 };
102
103 // 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 extern constexpr char c[6][4] = { "foo", "a", { "bar" }, { 'x', 'y', 'z' }, { "b" }, '1', '2', '3' };
105
Richard Smithfe587202012-04-15 02:50:59 +0000106 // CHECK: @_ZN5Array2ucE = constant [4 x i8] c"foo\00"
107 extern constexpr unsigned char uc[] = { "foo" };
108
Richard Smith2d6a5672012-01-14 04:30:29 +0000109 struct C { constexpr C() : n(5) {} int n, m = 3 * n + 1; };
Richard Smithe15c7122012-02-17 04:54:50 +0000110 // CHECK: @_ZN5Array5ctorsE = constant [3 x {{.*}}] [{{.*}} { i32 5, i32 16 }, {{.*}} { i32 5, i32 16 }, {{.*}} { i32 5, i32 16 }]
Richard Smith2d6a5672012-01-14 04:30:29 +0000111 extern const C ctors[3];
112 constexpr C ctors[3];
113
114 // CHECK: @_ZN5Array1dE = constant {{.*}} { [2 x i32] [i32 1, i32 2], [3 x i32] [i32 3, i32 4, i32 5] }
115 struct D { int n[2]; int m[3]; } extern constexpr d = { 1, 2, 3, 4, 5 };
Richard Smithf3908f22012-02-17 03:35:37 +0000116
117 struct E {
118 char c[4];
119 char d[4];
120 constexpr E() : c("foo"), d("x") {}
121 };
Richard Smithe15c7122012-02-17 04:54:50 +0000122 // CHECK: @_ZN5Array1eE = constant {{.*}} { [4 x i8] c"foo\00", [4 x i8] c"x\00\00\00" }
Richard Smithf3908f22012-02-17 03:35:37 +0000123 extern constexpr E e = E();
Richard Smithde31aa72012-07-07 22:48:24 +0000124
125 // PR13290
126 struct F { constexpr F() : n(4) {} int n; };
127 // CHECK: @_ZN5Array2f1E = global {{.*}} zeroinitializer
128 F f1[1][1][0] = { };
129 // CHECK: @_ZN5Array2f2E = global {{.* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4}}
130 F f2[2][2][2] = { };
Richard Smith2d6a5672012-01-14 04:30:29 +0000131}
132
133namespace MemberPtr {
134 struct B1 {
135 int a, b;
136 virtual void f();
137 void g();
138 };
139 struct B2 {
140 int c, d;
141 virtual void h();
142 void i();
143 };
144 struct C : B1 {
145 int e;
146 virtual void j();
147 void k();
148 };
149 struct D : C, B2 {
150 int z;
151 virtual void l();
152 void m();
153 };
154
155 // CHECK: @_ZN9MemberPtr2daE = constant i64 8
156 // CHECK: @_ZN9MemberPtr2dbE = constant i64 12
157 // CHECK: @_ZN9MemberPtr2dcE = constant i64 32
158 // CHECK: @_ZN9MemberPtr2ddE = constant i64 36
159 // CHECK: @_ZN9MemberPtr2deE = constant i64 16
160 // CHECK: @_ZN9MemberPtr2dzE = constant i64 40
161 extern constexpr int (D::*da) = &B1::a;
162 extern constexpr int (D::*db) = &C::b;
163 extern constexpr int (D::*dc) = &B2::c;
164 extern constexpr int (D::*dd) = &D::d;
165 extern constexpr int (D::*de) = &C::e;
166 extern constexpr int (D::*dz) = &D::z;
167
168 // CHECK: @_ZN9MemberPtr2baE = constant i64 8
169 // CHECK: @_ZN9MemberPtr2bbE = constant i64 12
170 // CHECK: @_ZN9MemberPtr2bcE = constant i64 8
171 // CHECK: @_ZN9MemberPtr2bdE = constant i64 12
172 // CHECK: @_ZN9MemberPtr2beE = constant i64 16
173 // CHECK: @_ZN9MemberPtr3b1zE = constant i64 40
174 // CHECK: @_ZN9MemberPtr3b2zE = constant i64 16
175 extern constexpr int (B1::*ba) = (int(B1::*))&B1::a;
176 extern constexpr int (B1::*bb) = (int(B1::*))&C::b;
177 extern constexpr int (B2::*bc) = (int(B2::*))&B2::c;
178 extern constexpr int (B2::*bd) = (int(B2::*))&D::d;
179 extern constexpr int (B1::*be) = (int(B1::*))&C::e;
180 extern constexpr int (B1::*b1z) = (int(B1::*))&D::z;
181 extern constexpr int (B2::*b2z) = (int(B2::*))&D::z;
182
183 // CHECK: @_ZN9MemberPtr2dfE = constant {{.*}} { i64 1, i64 0 }
184 // CHECK: @_ZN9MemberPtr2dgE = constant {{.*}} { i64 {{.*}}2B11gEv{{.*}}, i64 0 }
185 // CHECK: @_ZN9MemberPtr2dhE = constant {{.*}} { i64 1, i64 24 }
186 // CHECK: @_ZN9MemberPtr2diE = constant {{.*}} { i64 {{.*}}2B21iEv{{.*}}, i64 24 }
187 // CHECK: @_ZN9MemberPtr2djE = constant {{.*}} { i64 9, i64 0 }
188 // CHECK: @_ZN9MemberPtr2dkE = constant {{.*}} { i64 {{.*}}1C1kEv{{.*}}, i64 0 }
189 // CHECK: @_ZN9MemberPtr2dlE = constant {{.*}} { i64 17, i64 0 }
190 // CHECK: @_ZN9MemberPtr2dmE = constant {{.*}} { i64 {{.*}}1D1mEv{{.*}}, i64 0 }
191 extern constexpr void (D::*df)() = &C::f;
192 extern constexpr void (D::*dg)() = &B1::g;
193 extern constexpr void (D::*dh)() = &B2::h;
194 extern constexpr void (D::*di)() = &D::i;
195 extern constexpr void (D::*dj)() = &C::j;
196 extern constexpr void (D::*dk)() = &C::k;
197 extern constexpr void (D::*dl)() = &D::l;
198 extern constexpr void (D::*dm)() = &D::m;
199
200 // CHECK: @_ZN9MemberPtr2bfE = constant {{.*}} { i64 1, i64 0 }
201 // CHECK: @_ZN9MemberPtr2bgE = constant {{.*}} { i64 {{.*}}2B11gEv{{.*}}, i64 0 }
202 // CHECK: @_ZN9MemberPtr2bhE = constant {{.*}} { i64 1, i64 0 }
203 // CHECK: @_ZN9MemberPtr2biE = constant {{.*}} { i64 {{.*}}2B21iEv{{.*}}, i64 0 }
204 // CHECK: @_ZN9MemberPtr2bjE = constant {{.*}} { i64 9, i64 0 }
205 // CHECK: @_ZN9MemberPtr2bkE = constant {{.*}} { i64 {{.*}}1C1kEv{{.*}}, i64 0 }
206 // CHECK: @_ZN9MemberPtr3b1lE = constant {{.*}} { i64 17, i64 0 }
207 // CHECK: @_ZN9MemberPtr3b1mE = constant {{.*}} { i64 {{.*}}1D1mEv{{.*}}, i64 0 }
208 // CHECK: @_ZN9MemberPtr3b2lE = constant {{.*}} { i64 17, i64 -24 }
209 // CHECK: @_ZN9MemberPtr3b2mE = constant {{.*}} { i64 {{.*}}1D1mEv{{.*}}, i64 -24 }
210 extern constexpr void (B1::*bf)() = (void(B1::*)())&C::f;
211 extern constexpr void (B1::*bg)() = (void(B1::*)())&B1::g;
212 extern constexpr void (B2::*bh)() = (void(B2::*)())&B2::h;
213 extern constexpr void (B2::*bi)() = (void(B2::*)())&D::i;
214 extern constexpr void (B1::*bj)() = (void(B1::*)())&C::j;
215 extern constexpr void (B1::*bk)() = (void(B1::*)())&C::k;
216 extern constexpr void (B1::*b1l)() = (void(B1::*)())&D::l;
217 extern constexpr void (B1::*b1m)() = (void(B1::*)())&D::m;
218 extern constexpr void (B2::*b2l)() = (void(B2::*)())&D::l;
219 extern constexpr void (B2::*b2m)() = (void(B2::*)())&D::m;
220}
221
Richard Smith7ca48502012-02-13 22:16:19 +0000222namespace LiteralReference {
223 struct Lit {
224 constexpr Lit() : n(5) {}
225 int n;
226 };
227 // FIXME: This should have static initialization, but we do not implement
228 // that yet. For now, just check that we don't set the (pointer) value of
229 // the reference to 5!
230 //
231 // CHECK: @_ZN16LiteralReference3litE = global {{.*}} null
232 const Lit &lit = Lit();
233}
234
235namespace NonLiteralConstexpr {
236 constexpr int factorial(int n) {
237 return n ? factorial(n-1) * n : 1;
238 }
239 extern void f(int *p);
240
241 struct NonTrivialDtor {
242 constexpr NonTrivialDtor() : n(factorial(5)), p(&n) {}
243 ~NonTrivialDtor() {
244 f(p);
245 }
246
247 int n;
248 int *p;
249 };
250 static_assert(!__is_literal(NonTrivialDtor), "");
251 // CHECK: @_ZN19NonLiteralConstexpr3ntdE = global {{.*}} { i32 120, i32* getelementptr
252 NonTrivialDtor ntd;
253
254 struct VolatileMember {
255 constexpr VolatileMember() : n(5) {}
256 volatile int n;
257 };
258 static_assert(!__is_literal(VolatileMember), "");
259 // CHECK: @_ZN19NonLiteralConstexpr2vmE = global {{.*}} { i32 5 }
260 VolatileMember vm;
261
262 struct Both {
263 constexpr Both() : n(10) {}
264 ~Both();
265 volatile int n;
266 };
267 // CHECK: @_ZN19NonLiteralConstexpr1bE = global {{.*}} { i32 10 }
268 Both b;
269
270 void StaticVars() {
271 // CHECK: @_ZZN19NonLiteralConstexpr10StaticVarsEvE3ntd = {{.*}} { i32 120, i32* getelementptr {{.*}}
272 // CHECK: @_ZGVZN19NonLiteralConstexpr10StaticVarsEvE3ntd =
273 static NonTrivialDtor ntd;
274 // CHECK: @_ZZN19NonLiteralConstexpr10StaticVarsEvE2vm = {{.*}} { i32 5 }
275 // CHECK-NOT: @_ZGVZN19NonLiteralConstexpr10StaticVarsEvE2vm =
276 static VolatileMember vm;
277 // CHECK: @_ZZN19NonLiteralConstexpr10StaticVarsEvE1b = {{.*}} { i32 10 }
278 // CHECK: @_ZGVZN19NonLiteralConstexpr10StaticVarsEvE1b =
279 static Both b;
280 }
281}
282
Richard Smithc22adbd2012-02-23 08:33:23 +0000283// PR12067
284namespace VirtualMembers {
285 struct A {
286 constexpr A(double d) : d(d) {}
287 virtual void f();
288 double d;
289 };
290 struct B : A {
291 constexpr B() : A(2.0), c{'h', 'e', 'l', 'l', 'o'} {}
292 constexpr B(int n) : A(n), c{'w', 'o', 'r', 'l', 'd'} {}
293 virtual void g();
294 char c[5];
295 };
296 struct C {
297 constexpr C() : n(64) {}
298 int n;
299 };
300 struct D : C, A, B {
301 constexpr D() : A(1.0), B(), s(5) {}
302 short s;
303 };
304 struct E : D, B {
305 constexpr E() : B(3), c{'b','y','e'} {}
306 char c[3];
307 };
308
309 // 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" }
310 E e;
311
312 struct nsMemoryImpl {
313 virtual void f();
314 };
315 // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global { i8** } { i8** getelementptr inbounds ([3 x i8*]* @_ZTVN14VirtualMembers12nsMemoryImplE, i64 0, i64 2) }
316 static nsMemoryImpl sGlobalMemory;
317}
318
Richard Smithf4bb8d02012-07-05 08:39:21 +0000319namespace PR13273 {
320 struct U {
321 int t;
322 U() = default;
323 };
324
325 struct S : U {
326 S() = default;
327 };
328
Richard Smith8ae4ec22012-08-07 04:16:51 +0000329 // CHECK: @_ZN7PR132731sE = {{.*}} zeroinitializer
330 extern const S s {};
Richard Smithf4bb8d02012-07-05 08:39:21 +0000331}
332
Richard Smith2d6a5672012-01-14 04:30:29 +0000333// Constant initialization tests go before this point,
334// dynamic initialization tests go after.
335
Richard Smith7ca48502012-02-13 22:16:19 +0000336// We must emit a constant initializer for NonLiteralConstexpr::ntd, but also
337// emit an initializer to register its destructor.
338// CHECK: define {{.*}}cxx_global_var_init{{.*}}
339// CHECK-NOT: NonLiteralConstexpr
340// CHECK: call {{.*}}cxa_atexit{{.*}} @_ZN19NonLiteralConstexpr14NonTrivialDtorD1Ev {{.*}} @_ZN19NonLiteralConstexpr3ntdE
341// CHECK-NEXT: ret void
342
343// We don't need to emit any dynamic initialization for NonLiteralConstexpr::vm.
344// CHECK-NOT: NonLiteralConstexpr2vm
345
346// We must emit a constant initializer for NonLiteralConstexpr::b, but also
347// emit an initializer to register its destructor.
348// CHECK: define {{.*}}cxx_global_var_init{{.*}}
349// CHECK-NOT: NonLiteralConstexpr
350// CHECK: call {{.*}}cxa_atexit{{.*}} @_ZN19NonLiteralConstexpr4BothD1Ev {{.*}} @_ZN19NonLiteralConstexpr1bE
351// CHECK-NEXT: ret void
352
353// CHECK: define {{.*}}NonLiteralConstexpr10StaticVars
354// CHECK-NOT: }
355// CHECK: call {{.*}}cxa_atexit{{.*}}@_ZN19NonLiteralConstexpr14NonTrivialDtorD1Ev
356// CHECK-NOT: }
357// CHECK: call {{.*}}cxa_atexit{{.*}}@_ZN19NonLiteralConstexpr4BothD1Ev
358
Eli Friedman5930a4c2012-01-05 23:59:40 +0000359namespace CrossFuncLabelDiff {
360 // Make sure we refuse to constant-fold the variable b.
Richard Smith745f5142012-01-27 01:14:48 +0000361 constexpr long a(bool x) { return x ? 0 : (long)&&lbl + (0 && ({lbl: 0;})); }
362 void test() { static long b = (long)&&lbl - a(false); lbl: return; }
Eli Friedman5930a4c2012-01-05 23:59:40 +0000363 // CHECK: sub nsw i64 ptrtoint (i8* blockaddress(@_ZN18CrossFuncLabelDiff4testEv, {{.*}}) to i64),
364 // CHECK: store i64 {{.*}}, i64* @_ZZN18CrossFuncLabelDiff4testEvE1b, align 8
365}
Richard Smithce582fe2012-02-17 00:44:16 +0000366
367// PR12012
368namespace VirtualBase {
369 struct B {};
370 struct D : virtual B {};
371 D d;
372 // CHECK: call {{.*}}@_ZN11VirtualBase1DC1Ev
373
374 template<typename T> struct X : T {
375 constexpr X() : T() {}
376 };
377 X<D> x;
378 // CHECK: call {{.*}}@_ZN11VirtualBase1XINS_1DEEC1Ev
379}
Richard Smitha3ca41f2012-03-02 23:27:11 +0000380
381// PR12145
382namespace Unreferenced {
383 int n;
384 constexpr int *p = &n;
385 // We must not emit a load of 'p' here, since it's not odr-used.
386 int q = *p;
387 // CHECK-NOT: _ZN12Unreferenced1pE
388 // CHECK: = load i32* @_ZN12Unreferenced1nE
389 // CHECK-NEXT: store i32 {{.*}}, i32* @_ZN12Unreferenced1qE
390 // CHECK-NOT: _ZN12Unreferenced1pE
391
392 // Technically, we are not required to substitute variables of reference types
393 // initialized by constant expressions, because the special case for odr-use
394 // of variables in [basic.def.odr]p2 only applies to objects. But we do so
395 // anyway.
396
397 constexpr int &r = n;
398 // CHECK-NOT: _ZN12Unreferenced1rE
399 int s = r;
400
401 const int t = 1;
402 const int &rt = t;
403 int f(int);
404 int u = f(rt);
405 // CHECK: call i32 @_ZN12Unreferenced1fEi(i32 1)
406}
407
408namespace InitFromConst {
409 template<typename T> void consume(T);
410
411 const bool b = true;
412 const int n = 5;
Richard Smith946e2722012-03-07 01:58:44 +0000413 constexpr double d = 4.3;
Richard Smitha3ca41f2012-03-02 23:27:11 +0000414
415 struct S { int n = 7; S *p = 0; };
416 constexpr S s = S();
417 const S &r = s;
418 constexpr const S *p = &r;
419 constexpr int S::*mp = &S::n;
420 constexpr int a[3] = { 1, 4, 9 };
421
422 void test() {
423 // CHECK: call void @_ZN13InitFromConst7consumeIbEEvT_(i1 zeroext true)
424 consume(b);
425
426 // CHECK: call void @_ZN13InitFromConst7consumeIiEEvT_(i32 5)
427 consume(n);
428
429 // CHECK: call void @_ZN13InitFromConst7consumeIdEEvT_(double 4.300000e+00)
430 consume(d);
431
432 // CHECK: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
433 consume<const S&>(s);
434
Richard Smith5016a702012-10-20 01:38:33 +0000435 // CHECK: call void @_ZN13InitFromConst7consumeIRKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
Richard Smitha3ca41f2012-03-02 23:27:11 +0000436 consume<const S&>(r);
437
438 // CHECK: call void @_ZN13InitFromConst7consumeIPKNS_1SEEEvT_(%"struct.InitFromConst::S"* @_ZN13InitFromConstL1sE)
439 consume(p);
440
441 // CHECK: call void @_ZN13InitFromConst7consumeIMNS_1SEiEEvT_(i64 0)
442 consume(mp);
443
444 // CHECK: call void @_ZN13InitFromConst7consumeIPKiEEvT_(i32* getelementptr inbounds ([3 x i32]* @_ZN13InitFromConstL1aE, i32 0, i32 0))
445 consume(a);
446 }
447}
Richard Smith49149fe2012-04-08 08:02:07 +0000448
449namespace Null {
450 decltype(nullptr) null();
451 // CHECK: call {{.*}} @_ZN4Null4nullEv(
452 int *p = null();
453 struct S {};
454 // CHECK: call {{.*}} @_ZN4Null4nullEv(
455 int S::*q = null();
456}