| 1 |
// PR c++/117602 |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
|
| 4 |
auto x1 = [](decltype([&]{})){}; // { dg-error "non-local lambda" } |
| 5 |
|
| 6 |
auto x2 = [&]() { // { dg-error "non-local lambda" } |
| 7 |
[&]() { }; |
| 8 |
}; |
| 9 |
|
| 10 |
auto x3 = []() { |
| 11 |
[&]() { }; |
| 12 |
}; |
| 13 |
|
| 14 |
auto x4 = []() { |
| 15 |
[]() { }; |
| 16 |
}; |
| 17 |
|
| 18 |
auto x5 = [&]() { // { dg-error "non-local lambda" } |
| 19 |
[]() { }; |
| 20 |
}; |
| 21 |
|
| 22 |
void |
| 23 |
g () |
| 24 |
{ |
| 25 |
[&](decltype([&](decltype([=](decltype([&](decltype([&]() {})) {})) {})) {})){}; |
| 26 |
[&](decltype([&](decltype([&](decltype([&](decltype([&]() {})) {})) {})) {})){}; |
| 27 |
[=](decltype([=](decltype([=](decltype([=](decltype([&]() {})) {})) {})) {})){}; |
| 28 |
|
| 29 |
[=]() { |
| 30 |
[&]() { }; |
| 31 |
}; |
| 32 |
} |