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