aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual11.C
blob: f7b46d3098ffde94669d13bd6c9a07bbc171a04f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// P1064R0
// { dg-do compile }
// { dg-options "-std=c++2a" }

struct A
{
  constexpr virtual int f () const { return 1; }
};

struct B : public A
{
  constexpr virtual int f () const { return 2; }
};

struct C
{
  A a;
  B b;
};

constexpr C c;
constexpr const A &d = c.a;
constexpr const A &e = c.b;
constexpr const B &f = c.b;
static_assert (c.a.f () == 1 && c.b.f () == 2);
static_assert (d.f () == 1 && e.f () == 2 && f.f () == 2);