aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp23/consteval-if11.C
blob: a22736cc0063eb1009039faf649298c75754bb44 (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
// PR c++/102753
// { dg-do compile { target c++20 } }
// { dg-options "" }

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

consteval int foo () { return 42; }

constexpr int
bar ()
{
  if consteval {	// { dg-warning "'if consteval' only available with" "" { target c++20_only } }
    int (*fn1) () = foo;
    int (S::*fn2) () = &S::foo;
    int (S::*fn3) () = &S::bar;
    S s;
    return fn1 () + (s.*fn2) () + (s.*fn3) ();
  }
  return 0;
}

static_assert (bar () == 45);