Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested9a.C

raw
1 // PR c++/94376
2 // Like lambda-nested9.C but using explicit captures in the inner lambda.
3 // { dg-do compile { target c++11 } }
4
5 int main() {
6 // We used to incorrectly reject the first two cases.
7 int i = 0;
8 [=] () {
9 [i] () mutable {
10 ++i;
11 };
12 };
13
14 #if __cpp_init_captures
15 [j=0] () {
16 [j] () mutable {
17 ++j;
18 };
19 };
20 #endif
21
22 [=] () {
23 [&i] () mutable {
24 ++i; // { dg-error "read-only" }
25 };
26 };
27
28 const int j = 0;
29 [=] () {
30 [j] () mutable {
31 ++j; // { dg-error "read-only" }
32 };
33 };
34
35 #if __cpp_init_captures
36 [j=0] () {
37 [&j] () mutable {
38 ++j; // { dg-error "read-only" "" { target c++14 } }
39 };
40 };
41 #endif
42 }