Daily bump.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp2a / consteval-virtual5.C
blob85ad1182fb093acc98ae40b61a89f2834c371eb3
1 // { dg-do compile { target c++20 } }
3 struct B1;
4 struct B2;
5 struct D;
7 struct B1
9   virtual consteval const B1 *foo1 () const {return this;}
10   virtual consteval const B2 *foo2 (const D *) const;
12 struct B2
14   virtual consteval const B2 *baz1 () const {return this;}
15   virtual consteval const B1 *baz2 (const D *) const;
18 struct D : public B1, B2
20   virtual consteval const D *foo1 () const {return this;}
21   virtual consteval const D *foo2 (const D *d) const {return d;}
22   virtual consteval const D *baz1 () const {return this;}
23   virtual consteval const D *baz2 (const D *d) const {return d;}
26 consteval const B2 *B1::foo2 (const D *d) const {return d;}
27 consteval const B1 *B2::baz2 (const D *d) const {return d;}
29 consteval int
30 test (const B1 *b1, const B2 *b2, const D *d)
32   if (b1->foo1 () != b1)
33     return 1;
34   if (b2->baz1 () != b2)
35     return 2;
36   if (b1->foo2 (d) != b2)
37     return 3;
38   if (b2->baz2 (d) != b1)
39     return 4;
40   return 0;
43 consteval int
44 test (const D *d)
46   if (d->foo2 (d) != d)
47     return 11;
48   if (d->baz2 (d) != d)
49     return 12;
50   if (d->foo1 () != d)
51     return 13;
52   if (d->baz1 () != d)
53     return 14;
54   return 0;
57 constexpr D d;
58 constexpr auto e = test (&d, &d, &d);
59 constexpr auto f = test (&d);
60 static_assert (e == 0);
61 static_assert (f == 0);