8sa1-gcc/gcc/testsuite/g++.dg/cpp2a/lambda-this1.C
Marek Polacek e6a1e5fe73 P0806R2 - Deprecate implicit capture of this via [=]
P0806R2 - Deprecate implicit capture of this via [=]
	* lambda.c (add_default_capture): Formatting fixes.  Warn about
	deprecated implicit capture of this via [=].

	* g++.dg/cpp2a/lambda-this1.C: New test.
	* g++.dg/cpp2a/lambda-this2.C: New test.
	* g++.dg/cpp2a/lambda-this3.C: New test.

From-SVN: r263508
2018-08-13 15:46:42 +00:00

52 lines
1.1 KiB
C

// P0806R2
// { dg-do compile }
// { dg-options "-std=c++2a" }
struct X {
int x;
void foo (int n) {
auto a1 = [=] { x = n; }; // { dg-warning "implicit capture" }
auto a2 = [=, this] { x = n; };
auto a3 = [=, *this]() mutable { x = n; };
auto a4 = [&] { x = n; };
auto a5 = [&, this] { x = n; };
auto a6 = [&, *this]() mutable { x = n; };
auto a7 = [=] { // { dg-warning "implicit capture" }
auto a = [=] { // { dg-warning "implicit capture" }
auto a2 = [=] { x = n; }; // { dg-warning "implicit capture" }
};
};
auto a8 = [=, this] {
auto a = [=, this] {
auto a2 = [=, this] { x = n; };
};
};
auto a9 = [=, *this]() mutable {
auto a = [=, *this]() mutable {
auto a2 = [=, *this]() mutable { x = n; };
};
};
auto a10 = [&] {
auto a = [&] {
auto a2 = [&] { x = n; };
};
};
auto a11 = [&, this] {
auto a = [&, this] {
auto a2 = [&, this] { x = n; };
};
};
auto a12 = [&, *this]() mutable {
auto a = [&, *this]() mutable {
auto a2 = [&, *this]() mutable { x = n; };
};
};
}
};