| 1 |
// P1938R3 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
// { dg-options "" } |
| 4 |
|
| 5 |
// We used to give errors but the lambdas are now promoted to consteval |
| 6 |
// and are in a immediate function context, so no errors. |
| 7 |
|
| 8 |
consteval int foo (int x) { return x; } |
| 9 |
|
| 10 |
constexpr int |
| 11 |
bar (int x) |
| 12 |
{ |
| 13 |
int r = 0; |
| 14 |
if consteval // { dg-warning "'if consteval' only available with" "" { target c++20_only } } |
| 15 |
{ |
| 16 |
auto y = [=] { foo (x); }; |
| 17 |
y (); |
| 18 |
} |
| 19 |
return r; |
| 20 |
} |
| 21 |
|
| 22 |
template <typename T> |
| 23 |
constexpr T |
| 24 |
baz (T x) |
| 25 |
{ |
| 26 |
T r = 0; |
| 27 |
if consteval // { dg-warning "'if consteval' only available with" "" { target c++20_only } } |
| 28 |
{ |
| 29 |
auto y = [=] { foo (x); }; |
| 30 |
y (); |
| 31 |
} |
| 32 |
return r; |
| 33 |
} |
| 34 |
|
| 35 |
int |
| 36 |
qux (int x) |
| 37 |
{ |
| 38 |
return baz (x); |
| 39 |
} |