blob: 3e55c2b5c83e2076c05d1154dbbaf247f5a04f8a (
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
|
// { dg-do run }
// { dg-options "-std=c++2a" }
extern "C" void abort ();
namespace std {
constexpr inline bool
is_constant_evaluated () noexcept
{
return __builtin_is_constant_evaluated ();
}
}
int
main ()
{
constexpr int a = 5;
auto b = [] (int n) consteval { return n + a + std::is_constant_evaluated (); };
int c = b (4);
if (c != 10)
abort ();
auto d = [] () consteval { return a + std::is_constant_evaluated (); };
int e = d ();
if (e != 6)
abort ();
constexpr int f = d ();
if (f != 6)
abort ();
static_assert (d () == 6);
}
|