1*cf34dd0cSTyker // RUN: %clang_cc1 -std=gnu++2a -emit-pch %s -o %t.pch
2*cf34dd0cSTyker // RUN: %clang_cc1 -std=gnu++2a %s -DEMIT -ast-merge %t.pch -ast-dump-all | FileCheck %s
3*cf34dd0cSTyker
4*cf34dd0cSTyker // XFAIL: *
5*cf34dd0cSTyker
6*cf34dd0cSTyker #ifndef EMIT
7*cf34dd0cSTyker #define EMIT
8*cf34dd0cSTyker
9*cf34dd0cSTyker namespace Integer {
10*cf34dd0cSTyker
fint()11*cf34dd0cSTyker consteval int fint() {
12*cf34dd0cSTyker return 6789;
13*cf34dd0cSTyker }
14*cf34dd0cSTyker
15*cf34dd0cSTyker int Unique_Int = fint();
16*cf34dd0cSTyker //CHECK: VarDecl {{.*}} Unique_Int
17*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr {{.*}} 'int'
18*cf34dd0cSTyker //CHECK-NEXT: value: Int 6789
19*cf34dd0cSTyker
fint128()20*cf34dd0cSTyker consteval __uint128_t fint128() {
21*cf34dd0cSTyker return ((__uint128_t)0x75f17d6b3588f843 << 64) | 0xb13dea7c9c324e51;
22*cf34dd0cSTyker }
23*cf34dd0cSTyker
24*cf34dd0cSTyker constexpr __uint128_t Unique_Int128 = fint128();
25*cf34dd0cSTyker //CHECK: VarDecl {{.*}} Unique_Int128
26*cf34dd0cSTyker //CHECK-NEXT: value: Int 156773562844924187900898496343692168785
27*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
28*cf34dd0cSTyker //CHECK-NEXT: value: Int 156773562844924187900898496343692168785
29*cf34dd0cSTyker
30*cf34dd0cSTyker } // namespace Integer
31*cf34dd0cSTyker
32*cf34dd0cSTyker namespace FloatingPoint {
33*cf34dd0cSTyker
fdouble()34*cf34dd0cSTyker consteval double fdouble() {
35*cf34dd0cSTyker return double(567890.67890);
36*cf34dd0cSTyker }
37*cf34dd0cSTyker
38*cf34dd0cSTyker double Unique_Double = fdouble();
39*cf34dd0cSTyker //CHECK: VarDecl {{.*}} Unique_Double
40*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr {{.*}}
41*cf34dd0cSTyker //CHECK-NEXT: value: Float 5.678907e+05
42*cf34dd0cSTyker
43*cf34dd0cSTyker } // namespace FloatingPoint
44*cf34dd0cSTyker
45*cf34dd0cSTyker // FIXME: Add test for FixedPoint, ComplexInt, ComplexFloat, AddrLabelDiff.
46*cf34dd0cSTyker
47*cf34dd0cSTyker namespace Struct {
48*cf34dd0cSTyker
49*cf34dd0cSTyker struct B {
50*cf34dd0cSTyker int i;
51*cf34dd0cSTyker double d;
52*cf34dd0cSTyker };
53*cf34dd0cSTyker
fB()54*cf34dd0cSTyker consteval B fB() {
55*cf34dd0cSTyker return B{1, 0.7};
56*cf34dd0cSTyker }
57*cf34dd0cSTyker
58*cf34dd0cSTyker constexpr B Basic_Struct = fB();
59*cf34dd0cSTyker //CHECK: VarDecl {{.*}} Basic_Struct
60*cf34dd0cSTyker //CHECK-NEXT: value: Struct
61*cf34dd0cSTyker //CHECK-NEXT: fields: Int 1, Float 7.000000e-01
62*cf34dd0cSTyker //CHECK-NEXT: ImplicitCastExpr
63*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
64*cf34dd0cSTyker //CHECK-NEXT: value: Struct
65*cf34dd0cSTyker //CHECK-NEXT: fields: Int 1, Float 7.000000e-01
66*cf34dd0cSTyker
67*cf34dd0cSTyker struct C {
68*cf34dd0cSTyker int i = 9;
69*cf34dd0cSTyker };
70*cf34dd0cSTyker
71*cf34dd0cSTyker struct A : B {
AStruct::A72*cf34dd0cSTyker constexpr A(B b, int I, double D, C _c) : B(b), i(I), d(D), c(_c) {}
73*cf34dd0cSTyker int i;
74*cf34dd0cSTyker double d;
75*cf34dd0cSTyker C c;
76*cf34dd0cSTyker };
77*cf34dd0cSTyker
fA()78*cf34dd0cSTyker consteval A fA() {
79*cf34dd0cSTyker return A(Basic_Struct, 1, 79.789, {});
80*cf34dd0cSTyker }
81*cf34dd0cSTyker
82*cf34dd0cSTyker A Advanced_Struct = fA();
83*cf34dd0cSTyker //CHECK: VarDecl {{.*}} Advanced_Struct
84*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr {{.*}}
85*cf34dd0cSTyker //CHECK-NEXT: value: Struct
86*cf34dd0cSTyker //CHECK-NEXT: base: Struct
87*cf34dd0cSTyker //CHECK-NEXT: fields: Int 1, Float 7.000000e-01
88*cf34dd0cSTyker //CHECK-NEXT: fields: Int 1, Float 7.978900e+01
89*cf34dd0cSTyker //CHECK-NEXT: field: Struct
90*cf34dd0cSTyker //CHECK-NEXT: field: Int 9
91*cf34dd0cSTyker
92*cf34dd0cSTyker } // namespace Struct
93*cf34dd0cSTyker
94*cf34dd0cSTyker namespace Vector {
95*cf34dd0cSTyker
96*cf34dd0cSTyker using v4si = int __attribute__((__vector_size__(16)));
97*cf34dd0cSTyker
fv4si()98*cf34dd0cSTyker consteval v4si fv4si() {
99*cf34dd0cSTyker return (v4si){8, 2, 3};
100*cf34dd0cSTyker }
101*cf34dd0cSTyker
102*cf34dd0cSTyker v4si Vector_Int = fv4si();
103*cf34dd0cSTyker //CHECK: VarDecl {{.*}} Vector_Int
104*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
105*cf34dd0cSTyker //CHECK-NEXT: value: Vector length=4
106*cf34dd0cSTyker //CHECK-NEXT: elements: Int 8, Int 2, Int 3, Int 0
107*cf34dd0cSTyker
108*cf34dd0cSTyker } // namespace Vector
109*cf34dd0cSTyker
110*cf34dd0cSTyker namespace Array {
111*cf34dd0cSTyker
112*cf34dd0cSTyker struct B {
113*cf34dd0cSTyker int arr[6];
114*cf34dd0cSTyker };
115*cf34dd0cSTyker
fint()116*cf34dd0cSTyker consteval B fint() {
117*cf34dd0cSTyker return B{1, 2, 3, 4, 5, 6};
118*cf34dd0cSTyker }
119*cf34dd0cSTyker
120*cf34dd0cSTyker B Array_Int = fint();
121*cf34dd0cSTyker //CHECK: VarDecl {{.*}} Array_Int
122*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
123*cf34dd0cSTyker //CHECK-NEXT: value: Struct
124*cf34dd0cSTyker //CHECK-NEXT: field: Array size=6
125*cf34dd0cSTyker //CHECK-NEXT: elements: Int 1, Int 2, Int 3, Int 4
126*cf34dd0cSTyker //CHECK-NEXT: elements: Int 5, Int 6
127*cf34dd0cSTyker
128*cf34dd0cSTyker struct A {
129*cf34dd0cSTyker int i = 789;
130*cf34dd0cSTyker double d = 67890.09876;
131*cf34dd0cSTyker };
132*cf34dd0cSTyker
133*cf34dd0cSTyker struct C {
134*cf34dd0cSTyker A arr[3];
135*cf34dd0cSTyker };
136*cf34dd0cSTyker
fA()137*cf34dd0cSTyker consteval C fA() {
138*cf34dd0cSTyker return {{A{}, A{-45678, 9.8}, A{9}}};
139*cf34dd0cSTyker }
140*cf34dd0cSTyker
141*cf34dd0cSTyker C Array2_Struct = fA();
142*cf34dd0cSTyker //CHECK: VarDecl {{.*}} Array2_Struct
143*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr {{.*}}
144*cf34dd0cSTyker
145*cf34dd0cSTyker using v4si = int __attribute__((__vector_size__(16)));
146*cf34dd0cSTyker
147*cf34dd0cSTyker struct D {
148*cf34dd0cSTyker v4si arr[2];
149*cf34dd0cSTyker };
150*cf34dd0cSTyker
fv4si()151*cf34dd0cSTyker consteval D fv4si() {
152*cf34dd0cSTyker return {{{1, 2, 3, 4}, {4, 5, 6, 7}}};
153*cf34dd0cSTyker }
154*cf34dd0cSTyker
155*cf34dd0cSTyker D Array_Vector = fv4si();
156*cf34dd0cSTyker //CHECK: VarDecl {{.*}} Array_Vector
157*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr {{.*}}
158*cf34dd0cSTyker //CHECK-NEXT: value: Struct
159*cf34dd0cSTyker //CHECK-NEXT: field: Array size=2
160*cf34dd0cSTyker //CHECK-NEXT: element: Vector length=4
161*cf34dd0cSTyker //CHECK-NEXT: elements: Int 1, Int 2, Int 3, Int 4
162*cf34dd0cSTyker //CHECK-NEXT: element: Vector length=4
163*cf34dd0cSTyker //CHECK-NEXT: elements: Int 4, Int 5, Int 6, Int 7
164*cf34dd0cSTyker
165*cf34dd0cSTyker } // namespace Array
166*cf34dd0cSTyker
167*cf34dd0cSTyker namespace Union {
168*cf34dd0cSTyker
169*cf34dd0cSTyker struct A {
170*cf34dd0cSTyker int i = 6789;
171*cf34dd0cSTyker float f = 987.9876;
172*cf34dd0cSTyker };
173*cf34dd0cSTyker
174*cf34dd0cSTyker union U {
175*cf34dd0cSTyker int i;
176*cf34dd0cSTyker A a{567890, 9876.5678f};
177*cf34dd0cSTyker };
178*cf34dd0cSTyker
fU1()179*cf34dd0cSTyker consteval U fU1() {
180*cf34dd0cSTyker return U{0};
181*cf34dd0cSTyker }
182*cf34dd0cSTyker
183*cf34dd0cSTyker U Unique_Union1 = fU1();
184*cf34dd0cSTyker //CHECK: VarDecl {{.*}} Unique_Union
185*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
186*cf34dd0cSTyker //CHECK-NEXT: value: Union .i Int 0
187*cf34dd0cSTyker
fU()188*cf34dd0cSTyker consteval U fU() {
189*cf34dd0cSTyker return U{};
190*cf34dd0cSTyker }
191*cf34dd0cSTyker
192*cf34dd0cSTyker U Unique_Union2 = fU();
193*cf34dd0cSTyker //CHECK: VarDecl {{.*}} Unique_Union
194*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
195*cf34dd0cSTyker //CHECK-NEXT: value: Union .a
196*cf34dd0cSTyker //CHECK-NEXT: Struct
197*cf34dd0cSTyker //CHECK-NEXT: fields: Int 567890, Float 9.876567e+03
198*cf34dd0cSTyker
199*cf34dd0cSTyker } // namespace Union
200*cf34dd0cSTyker
201*cf34dd0cSTyker namespace MemberPointer {
202*cf34dd0cSTyker
203*cf34dd0cSTyker struct A {
204*cf34dd0cSTyker struct B {
205*cf34dd0cSTyker struct C {
206*cf34dd0cSTyker struct D {
207*cf34dd0cSTyker struct E {
208*cf34dd0cSTyker struct F {
209*cf34dd0cSTyker struct G {
210*cf34dd0cSTyker int i;
211*cf34dd0cSTyker };
212*cf34dd0cSTyker };
213*cf34dd0cSTyker };
214*cf34dd0cSTyker };
215*cf34dd0cSTyker };
216*cf34dd0cSTyker };
217*cf34dd0cSTyker };
218*cf34dd0cSTyker
fmem_ptr()219*cf34dd0cSTyker consteval auto fmem_ptr() -> decltype(&A::B::C::D::E::F::G::i) {
220*cf34dd0cSTyker return &A::B::C::D::E::F::G::i;
221*cf34dd0cSTyker }
222*cf34dd0cSTyker
223*cf34dd0cSTyker auto MemberPointer1 = fmem_ptr();
224*cf34dd0cSTyker //CHECK: VarDecl {{.*}} MemberPointer1
225*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
226*cf34dd0cSTyker //CHECK-NEXT: value: MemberPointer &G::i
227*cf34dd0cSTyker
228*cf34dd0cSTyker struct A1 {
229*cf34dd0cSTyker struct B1 {
fMemberPointer::A1::B1230*cf34dd0cSTyker int f() const {
231*cf34dd0cSTyker return 0;
232*cf34dd0cSTyker }
233*cf34dd0cSTyker };
234*cf34dd0cSTyker };
235*cf34dd0cSTyker
fmem_ptr2()236*cf34dd0cSTyker consteval auto fmem_ptr2() {
237*cf34dd0cSTyker return &A1::B1::f;
238*cf34dd0cSTyker }
239*cf34dd0cSTyker
240*cf34dd0cSTyker auto MemberPointer2 = fmem_ptr2();
241*cf34dd0cSTyker //CHECK: VarDecl {{.*}} MemberPointer2
242*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
243*cf34dd0cSTyker //CHECK-NEXT: value: MemberPointer &B1::f
244*cf34dd0cSTyker
245*cf34dd0cSTyker } // namespace MemberPointer
246*cf34dd0cSTyker
247*cf34dd0cSTyker namespace std {
248*cf34dd0cSTyker struct type_info;
249*cf34dd0cSTyker };
250*cf34dd0cSTyker
251*cf34dd0cSTyker namespace LValue {
252*cf34dd0cSTyker
253*cf34dd0cSTyker constexpr int g = 0;
254*cf34dd0cSTyker
fg_ref()255*cf34dd0cSTyker consteval const int &fg_ref() {
256*cf34dd0cSTyker return g;
257*cf34dd0cSTyker }
258*cf34dd0cSTyker
259*cf34dd0cSTyker const int &g_ref = fg_ref();
260*cf34dd0cSTyker //CHECK: VarDecl {{.*}} g_ref
261*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
262*cf34dd0cSTyker //CHECK-NEXT: value: LValue &g
263*cf34dd0cSTyker
fint_ptr()264*cf34dd0cSTyker consteval const int *fint_ptr() {
265*cf34dd0cSTyker return &g;
266*cf34dd0cSTyker }
267*cf34dd0cSTyker
268*cf34dd0cSTyker const int *g_ptr = fint_ptr();
269*cf34dd0cSTyker //CHECK: VarDecl {{.*}} g_ptr
270*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
271*cf34dd0cSTyker //CHECK-NEXT: value: LValue &g
272*cf34dd0cSTyker
fnull_ptr()273*cf34dd0cSTyker consteval const int *fnull_ptr() {
274*cf34dd0cSTyker return nullptr;
275*cf34dd0cSTyker }
276*cf34dd0cSTyker
277*cf34dd0cSTyker const int *ptr2 = fnull_ptr();
278*cf34dd0cSTyker //CHECK: VarDecl {{.*}} ptr2
279*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
280*cf34dd0cSTyker //CHECK-NEXT: value: LValue nullptr
281*cf34dd0cSTyker
282*cf34dd0cSTyker int fconst();
283*cf34dd0cSTyker
ffunc_ptr()284*cf34dd0cSTyker consteval auto ffunc_ptr() {
285*cf34dd0cSTyker return &fconst;
286*cf34dd0cSTyker }
287*cf34dd0cSTyker
288*cf34dd0cSTyker int (*func_ptr)() = ffunc_ptr();
289*cf34dd0cSTyker //CHECK: VarDecl {{.*}} func_ptr
290*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr {{.*}}
291*cf34dd0cSTyker //CHECK-NEXT: value: LValue &fconst
292*cf34dd0cSTyker
293*cf34dd0cSTyker struct A {
294*cf34dd0cSTyker int Arr[6] = {0, 1, 3, 4, 5, 9};
295*cf34dd0cSTyker int i = 0;
296*cf34dd0cSTyker };
297*cf34dd0cSTyker
298*cf34dd0cSTyker struct D {
299*cf34dd0cSTyker A arr[6] = {};
300*cf34dd0cSTyker };
301*cf34dd0cSTyker
fA()302*cf34dd0cSTyker consteval D fA() {
303*cf34dd0cSTyker return {};
304*cf34dd0cSTyker }
305*cf34dd0cSTyker
306*cf34dd0cSTyker constexpr D Arr = fA();
307*cf34dd0cSTyker // CHECK: VarDecl {{.*}} Arr
308*cf34dd0cSTyker // CHECK-NEXT: value: Struct
309*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
310*cf34dd0cSTyker // CHECK-NEXT: element: Struct
311*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
312*cf34dd0cSTyker // CHECK-NEXT: elements: Int 0, Int 1, Int 3, Int 4
313*cf34dd0cSTyker // CHECK-NEXT: elements: Int 5, Int 9
314*cf34dd0cSTyker // CHECK-NEXT: field: Int 0
315*cf34dd0cSTyker // CHECK-NEXT: element: Struct
316*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
317*cf34dd0cSTyker // CHECK-NEXT: elements: Int 0, Int 1, Int 3, Int 4
318*cf34dd0cSTyker // CHECK-NEXT: elements: Int 5, Int 9
319*cf34dd0cSTyker // CHECK-NEXT: field: Int 0
320*cf34dd0cSTyker // CHECK-NEXT: element: Struct
321*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
322*cf34dd0cSTyker // CHECK-NEXT: elements: Int 0, Int 1, Int 3, Int 4
323*cf34dd0cSTyker // CHECK-NEXT: elements: Int 5, Int 9
324*cf34dd0cSTyker // CHECK-NEXT: field: Int 0
325*cf34dd0cSTyker // CHECK-NEXT: element: Struct
326*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
327*cf34dd0cSTyker // CHECK-NEXT: elements: Int 0, Int 1, Int 3, Int 4
328*cf34dd0cSTyker // CHECK-NEXT: elements: Int 5, Int 9
329*cf34dd0cSTyker // CHECK-NEXT: field: Int 0
330*cf34dd0cSTyker // CHECK-NEXT: element: Struct
331*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
332*cf34dd0cSTyker // CHECK-NEXT: elements: Int 0, Int 1, Int 3, Int 4
333*cf34dd0cSTyker // CHECK-NEXT: elements: Int 5, Int 9
334*cf34dd0cSTyker // CHECK-NEXT: field: Int 0
335*cf34dd0cSTyker // CHECK-NEXT: element: Struct
336*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
337*cf34dd0cSTyker // CHECK-NEXT: elements: Int 0, Int 1, Int 3, Int 4
338*cf34dd0cSTyker // CHECK-NEXT: elements: Int 5, Int 9
339*cf34dd0cSTyker // CHECK-NEXT: field: Int 0
340*cf34dd0cSTyker // CHECK-NEXT: ImplicitCastExpr
341*cf34dd0cSTyker // CHECK-NEXT: ConstantExpr
342*cf34dd0cSTyker // CHECK-NEXT: value: Struct
343*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
344*cf34dd0cSTyker // CHECK-NEXT: element: Struct
345*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
346*cf34dd0cSTyker // CHECK-NEXT: elements: Int 0, Int 1, Int 3, Int 4
347*cf34dd0cSTyker // CHECK-NEXT: elements: Int 5, Int 9
348*cf34dd0cSTyker // CHECK-NEXT: field: Int 0
349*cf34dd0cSTyker // CHECK-NEXT: element: Struct
350*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
351*cf34dd0cSTyker // CHECK-NEXT: elements: Int 0, Int 1, Int 3, Int 4
352*cf34dd0cSTyker // CHECK-NEXT: elements: Int 5, Int 9
353*cf34dd0cSTyker // CHECK-NEXT: field: Int 0
354*cf34dd0cSTyker // CHECK-NEXT: element: Struct
355*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
356*cf34dd0cSTyker // CHECK-NEXT: elements: Int 0, Int 1, Int 3, Int 4
357*cf34dd0cSTyker // CHECK-NEXT: elements: Int 5, Int 9
358*cf34dd0cSTyker // CHECK-NEXT: field: Int 0
359*cf34dd0cSTyker // CHECK-NEXT: element: Struct
360*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
361*cf34dd0cSTyker // CHECK-NEXT: elements: Int 0, Int 1, Int 3, Int 4
362*cf34dd0cSTyker // CHECK-NEXT: elements: Int 5, Int 9
363*cf34dd0cSTyker // CHECK-NEXT: field: Int 0
364*cf34dd0cSTyker // CHECK-NEXT: element: Struct
365*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
366*cf34dd0cSTyker // CHECK-NEXT: elements: Int 0, Int 1, Int 3, Int 4
367*cf34dd0cSTyker // CHECK-NEXT: elements: Int 5, Int 9
368*cf34dd0cSTyker // CHECK-NEXT: field: Int 0
369*cf34dd0cSTyker // CHECK-NEXT: element: Struct
370*cf34dd0cSTyker // CHECK-NEXT: field: Array size=6
371*cf34dd0cSTyker // CHECK-NEXT: elements: Int 0, Int 1, Int 3, Int 4
372*cf34dd0cSTyker // CHECK-NEXT: elements: Int 5, Int 9
373*cf34dd0cSTyker // CHECK-NEXT: field: Int 0
374*cf34dd0cSTyker
fconstintref()375*cf34dd0cSTyker consteval const int &fconstintref() {
376*cf34dd0cSTyker return Arr.arr[0].i;
377*cf34dd0cSTyker }
378*cf34dd0cSTyker
379*cf34dd0cSTyker const int &ArrayStructRef1 = fconstintref();
380*cf34dd0cSTyker //CHECK: VarDecl {{.*}} ArrayStructRef1
381*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
382*cf34dd0cSTyker //CHECK-NEXT: value: LValue &Arr.arr[0].i
383*cf34dd0cSTyker
fconstintref2()384*cf34dd0cSTyker consteval const int &fconstintref2() {
385*cf34dd0cSTyker return Arr.arr[1].Arr[5];
386*cf34dd0cSTyker }
387*cf34dd0cSTyker
388*cf34dd0cSTyker const int &ArrayStructRef2 = fconstintref2();
389*cf34dd0cSTyker //CHECK: VarDecl {{.*}} ArrayStructRef2
390*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
391*cf34dd0cSTyker //CHECK-NEXT: value: LValue &Arr.arr[1].Arr[5]
392*cf34dd0cSTyker
fconststar()393*cf34dd0cSTyker consteval const int *fconststar() {
394*cf34dd0cSTyker return &ArrayStructRef2;
395*cf34dd0cSTyker }
396*cf34dd0cSTyker
397*cf34dd0cSTyker const int *ArrayStructRef3 = fconststar();
398*cf34dd0cSTyker //CHECK: VarDecl {{.*}} ArrayStructRef3
399*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
400*cf34dd0cSTyker //CHECK-NEXT: value: LValue &Arr.arr[1].Arr[5]
401*cf34dd0cSTyker
402*cf34dd0cSTyker struct B : A {
403*cf34dd0cSTyker };
404*cf34dd0cSTyker
405*cf34dd0cSTyker struct C {
406*cf34dd0cSTyker B b;
407*cf34dd0cSTyker };
408*cf34dd0cSTyker
fC()409*cf34dd0cSTyker consteval C fC() {
410*cf34dd0cSTyker return {};
411*cf34dd0cSTyker }
412*cf34dd0cSTyker
413*cf34dd0cSTyker C c = fC();
414*cf34dd0cSTyker //CHECK: VarDecl {{.*}} c
415*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
416*cf34dd0cSTyker //CHECK-NEXT: value: Struct
417*cf34dd0cSTyker //CHECK-NEXT: field: Struct
418*cf34dd0cSTyker //CHECK-NEXT: base: Struct
419*cf34dd0cSTyker //CHECK-NEXT: field: Array size=6
420*cf34dd0cSTyker //CHECK-NEXT: elements: Int 0, Int 1, Int 3, Int 4
421*cf34dd0cSTyker //CHECK-NEXT: elements: Int 5, Int 9
422*cf34dd0cSTyker //CHECK-NEXT: field: Int 0
423*cf34dd0cSTyker
f2constintref()424*cf34dd0cSTyker consteval const int &f2constintref() {
425*cf34dd0cSTyker return c.b.i;
426*cf34dd0cSTyker }
427*cf34dd0cSTyker
428*cf34dd0cSTyker const int &StructPathRef = f2constintref();
429*cf34dd0cSTyker //CHECK: VarDecl {{.*}} StructPathRef
430*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
431*cf34dd0cSTyker //CHECK-NEXT: value: LValue &c.b.A::i
432*cf34dd0cSTyker
ftype_info()433*cf34dd0cSTyker consteval const std::type_info *ftype_info() {
434*cf34dd0cSTyker return &typeid(c);
435*cf34dd0cSTyker }
436*cf34dd0cSTyker
437*cf34dd0cSTyker const std::type_info *T1 = ftype_info();
438*cf34dd0cSTyker //CHECK: VarDecl {{.*}} T1
439*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
440*cf34dd0cSTyker //CHECK-NEXT:value: LValue &typeid(LValue::C)
441*cf34dd0cSTyker
ftype_info2()442*cf34dd0cSTyker consteval const std::type_info *ftype_info2() {
443*cf34dd0cSTyker return &typeid(Arr.arr[1].Arr[2]);
444*cf34dd0cSTyker }
445*cf34dd0cSTyker
446*cf34dd0cSTyker const std::type_info *T2 = ftype_info2();
447*cf34dd0cSTyker //CHECK: VarDecl {{.*}} T2
448*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
449*cf34dd0cSTyker //CHECK-NEXT: value: LValue &typeid(int)
450*cf34dd0cSTyker
fstring()451*cf34dd0cSTyker consteval const char *fstring() {
452*cf34dd0cSTyker return "test";
453*cf34dd0cSTyker }
454*cf34dd0cSTyker
455*cf34dd0cSTyker const char *cptr = fstring();
456*cf34dd0cSTyker //CHECK: VarDecl {{.*}} cptr
457*cf34dd0cSTyker //CHECK-NEXT: ConstantExpr
458*cf34dd0cSTyker //CHECK-NEXT: value: LValue &"test"[0]
459*cf34dd0cSTyker
460*cf34dd0cSTyker } // namespace LValue
461*cf34dd0cSTyker
462*cf34dd0cSTyker #endif
463