Debian Codegraph @

gcc/testsuite/g++.dg/cpp26/pack-indexing22.C

raw
1 // PR c++/124487
2 // { dg-do compile { target c++20 } }
3 // { dg-options "" }
4
5 template <int I, typename... T>
6 struct A {
7 using B = T...[I]; // { dg-warning "pack indexing only available with" "" { target c++23_down } }
8 A () requires (requires { B {}; }) {}
9 };
10
11 template <int I, auto... J>
12 struct C {
13 using B = decltype (J...[I]); // { dg-warning "pack indexing only available with" "" { target c++23_down } }
14 C () requires (requires { B {}; }) {}
15 };
16
17 template <int I, auto... J>
18 decltype (J...[I]) foo () { return 0; } // { dg-warning "pack indexing only available with" "" { target c++23_down } }
19
20 template <int I, typename... T>
21 T...[I] bar () { return 0; } // { dg-warning "pack indexing only available with" "" { target c++23_down } }
22
23 template <int I, typename... T>
24 using D = T...[I]; // { dg-warning "pack indexing only available with" "" { target c++23_down } }
25
26 template <int I, typename... T>
27 void baz (D <I, int, T...>) {}
28
29 template <auto... J>
30 decltype (J...[1]) corge () { return 0; } // { dg-warning "pack indexing only available with" "" { target c++23_down } }
31
32 void
33 qux ()
34 {
35 // { dg-final { scan-assembler "_ZN1AILi3EJilsiEEC1EvQrqXtlDyT0_T_EE" } }
36 A <3, int, long, short, int> a;
37 // { dg-final { scan-assembler "_ZN1CILi2EJLi0ELx0ELj0ELl0EEEC1EvQrqXtlDtsyT0_T_EEE" } }
38 C <2, 0, 0LL, 0U, 0L> c;
39 // { dg-final { scan-assembler "_Z3fooILi0ETpTnDaJLi1EEEDtsyT0_T_Ev" } }
40 foo <0, 1> ();
41 // { dg-final { scan-assembler "_Z3fooILi2ETpTnDaJLj1ELl2ELx3ELd4010000000000000EEEDtsyT0_T_Ev" } }
42 foo <2, 1U, 2L, 3LL, 4.0> ();
43 // { dg-final { scan-assembler "_Z3barILi0EJiEEDyT0_T_v" } }
44 bar <0, int> ();
45 // { dg-final { scan-assembler "_Z3barILi3EJjlxdEEDyT0_T_v" } }
46 bar <3, unsigned, long, long long, double> ();
47 // baz <0, int> ();
48 // { dg-final { scan-assembler "_Z5corgeITpTnDaJLi1ELx2ELj3ELl4ELi5EEEDtsyT_L\[jmy]1EEv" } }
49 corge <1, 2LL, 3U, 4L, 5> ();
50 }