aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/consteval22.C
blob: 5c3637189dc0593228e5dbe2426f57531ee98cc3 (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
29
30
31
32
33
34
// PR c++/102753
// { dg-do compile { target c++20 } }

struct S {
  constexpr S () : s (0) {}
  consteval int foo () { return 1; }
  virtual consteval int bar () { return 2; }
  int s;
};
typedef int (S::*P) ();

consteval P
foo ()
{
  return &S::foo;
}

consteval P
bar ()
{
  return &S::bar;
}

consteval int
baz ()
{
  S s;
  return (s.*(foo ())) () + (s.*(bar ())) ();
}

static_assert (baz () == 3);

constexpr P a = foo ();		// { dg-error "immediate evaluation returns address of immediate function" }
constexpr P b = bar ();		// { dg-error "immediate evaluation returns address of immediate function" }