aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/consteval41.C
blob: 76c4a5d2fff7c2a568ec93519a7fd79f63150b15 (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
35
36
37
// PR c++/119150
// { dg-do run { target c++20 } }

consteval bool
foo (bool x)
{
  return x;
}

constexpr bool
bar ()
{
#if __cpp_if_consteval >= 202106L
  if consteval
    {
      return true;
    }
  else
    {
      return false;
    }
#else
  return __builtin_is_constant_evaluated ();
#endif
}

int
main ()
{
  bool a = false;
  a = foo (bar ());
  if (!a)
    __builtin_abort ();
  bool b = foo (bar ());
  if (!b)
    __builtin_abort ();
}