Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/nontype-class1.C

raw
1 // { dg-do compile { target c++20 } }
2 // { dg-additional-options "-fdelete-null-pointer-checks" }
3
4 struct A
5 {
6 int i;
7 constexpr A (int i): i(i) {}
8 // auto operator<=> (const A&) = default;
9 };
10
11 template <A a>
12 struct B
13 {
14 static constexpr int i = a.i;
15 static constexpr A const* ap = &a;
16 };
17
18 template <A a>
19 struct C
20 {
21 static constexpr A const* ap = &a;
22 };
23
24 static_assert(B<1>::i == 1);
25 static_assert(B<2>::i == 2);
26 static_assert(B<1>::ap == C<1>::ap);
27 static_assert(B<1>::ap != C<2>::ap);
28
29 // { dg-final { scan-assembler "_Z1fP1BIXtl1ALi1EEEE" } }
30 // { dg-final { scan-assembler "_ZTAXtl1ALi1EEE" } }
31 const void* f(B<1> *p) {
32 constexpr int i = p->ap->i;
33 return p->ap;
34 }