2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / cpp2a / lambda-this1.C
bloba31b968800d617dced5e40095d7672be267a38c5
1 // P0806R2
2 // { dg-do compile }
3 // { dg-options "-std=c++2a" }
5 struct X {
6   int x;
7   void foo (int n) {
8     auto a1 = [=] { x = n; }; // { dg-warning "implicit capture" }
9     auto a2 = [=, this] { x = n; };
10     auto a3 = [=, *this]() mutable { x = n; };
11     auto a4 = [&] { x = n; };
12     auto a5 = [&, this] { x = n; };
13     auto a6 = [&, *this]() mutable { x = n; };
15     auto a7 = [=] { // { dg-warning "implicit capture" }
16       auto a = [=] { // { dg-warning "implicit capture" }
17          auto a2 = [=] { x = n; }; // { dg-warning "implicit capture" }
18       };
19     };
21     auto a8 = [=, this] {
22       auto a = [=, this] {
23          auto a2 = [=, this] { x = n; };
24       };
25     };
27     auto a9 = [=, *this]() mutable {
28       auto a = [=, *this]() mutable {
29          auto a2 = [=, *this]() mutable { x = n; };
30       };
31     };
33     auto a10 = [&] {
34       auto a = [&] {
35          auto a2 = [&] { x = n; };
36       };
37     };
39     auto a11 = [&, this] {
40       auto a = [&, this] {
41          auto a2 = [&, this] { x = n; };
42       };
43     };
45     auto a12 = [&, *this]() mutable {
46       auto a = [&, *this]() mutable {
47          auto a2 = [&, *this]() mutable { x = n; };
48       };
49     };
50   }