aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual17.C
blob: a8a89952626f41ba1752728aa78aedd2431b965c (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
27
28
// PR c++/93310
// { dg-do compile { target c++20 } }

struct A
{
  virtual constexpr char f () const
  { return 'A'; }
};

struct B : A
{
  char x;

  constexpr B () : x (0)
  { x = ((A *)this)->f(); }

  virtual constexpr char f () const
  { return 'B'; }
};

struct C : B
{
  virtual constexpr char f () const
  { return 'C'; }
};

constexpr C c;
static_assert (c.x == 'B');