| 1 |
// Testcase from N2998 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
void f1(int i) { |
| 5 |
int const N = 20; |
| 6 |
auto m1 = [=]{ |
| 7 |
int const M = 30; |
| 8 |
auto m2 = [i]{ |
| 9 |
int x[N][M]; // OK: N and M are not "used" |
| 10 |
x[0][0] = i; // OK: i is explicitly captured by m2 |
| 11 |
// and implicitly captured by m1 |
| 12 |
}; |
| 13 |
}; |
| 14 |
struct s1 { |
| 15 |
int f; |
| 16 |
void work(int n) { |
| 17 |
int m = n*n; |
| 18 |
int j = 40; |
| 19 |
auto m3 = [this,m]{ |
| 20 |
/*auto m4=*/[&,j]{ // { dg-error "j. is not captured" } |
| 21 |
int x = n; // { dg-error "n. is not captured" } |
| 22 |
x += m; // OK: m implicitly captured by m4 |
| 23 |
// and explicitly captured by m3 |
| 24 |
x += i; // { dg-error "i. is not captured" } |
| 25 |
x += f; // OK: this captured implicitly by m4 |
| 26 |
// and explicitly by m3 |
| 27 |
}; |
| 28 |
}; |
| 29 |
} |
| 30 |
}; |
| 31 |
} |