8sa1-gcc/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested.C
Marek Polacek e00dfa841f array-init.c: Add dg-prune-output.
* c-c++-common/array-init.c: Add dg-prune-output.
	* g++.dg/cpp0x/lambda/lambda-const-this.C: Add dg-warning.
	* g++.dg/cpp0x/lambda/lambda-in-class-neg.C: Likewise.
	* g++.dg/cpp0x/lambda/lambda-in-class.C: Likewise.
	* g++.dg/cpp0x/lambda/lambda-nested.C: Likewise.
	* g++.dg/cpp0x/lambda/lambda-nsdmi1.C: Likewise.
	* g++.dg/cpp0x/lambda/lambda-nsdmi4.C: Likewise.
	* g++.dg/cpp0x/lambda/lambda-this.C: Likewise.
	* g++.dg/cpp0x/lambda/lambda-this17.C: Likewise.
	* g++.dg/cpp0x/lambda/lambda-this18.C: Likewise.
	* g++.dg/cpp0x/lambda/lambda-this2.C: Likewise.
	* g++.dg/cpp0x/lambda/lambda-this8.C: Likewise.
	* g++.dg/cpp1y/pr64382.C: Likewise.
	* g++.dg/cpp1y/pr77739.C: Likewise.
	* g++.dg/cpp1z/lambda-this1.C: Likewise.
	* g++.dg/cpp1z/lambda-this2.C: Likewise.
	* g++.dg/template/crash84.C: Adjust dg-error.

From-SVN: r264169
2018-09-08 14:27:25 +00:00

63 lines
785 B
C

// { dg-do run { target c++11 } }
#include <cassert>
struct A {
int i;
A(): i(42) { }
int f() {
return [this]{
return [=]{ return i; }(); // { dg-warning "implicit capture" "" { target c++2a } }
}();
}
};
int main() {
int i = 1;
[] (int& i) -> void {
[&] () -> void {
i = 2;
} ();
} (i);
assert(i == 2);
[&] () -> void {
[&i] () -> void {
i = 3;
} ();
} ();
assert(i == 3);
[&] () -> void {
[&] () -> void {
i = 4;
} ();
} ();
assert(i == 4);
i = 4;
[&] () -> void {
[=] () mutable -> void {
i = 5;
} ();
} ();
assert(i == 4);
[=] () mutable -> void {
[&] () -> void {
i = 6;
} ();
} ();
assert(i == 4);
assert (A().f() == 42);
return 0;
}