blob: b8709beba85fed188f4ce902fab3fef4c43f6e66 (
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
38
39
|
// P1938R3
// { dg-do compile { target c++20 } }
// { dg-options "" }
// We used to give errors but the lambdas are now promoted to consteval
// and are in a immediate function context, so no errors.
consteval int foo (int x) { return x; }
constexpr int
bar (int x)
{
int r = 0;
if consteval // { dg-warning "'if consteval' only available with" "" { target c++20_only } }
{
auto y = [=] { foo (x); };
y ();
}
return r;
}
template <typename T>
constexpr T
baz (T x)
{
T r = 0;
if consteval // { dg-warning "'if consteval' only available with" "" { target c++20_only } }
{
auto y = [=] { foo (x); };
y ();
}
return r;
}
int
qux (int x)
{
return baz (x);
}
|