8sa1-gcc/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this21.C
Marek Polacek 22f6d17441 PR c++/66999 - 'this' captured by reference.
* parser.c (cp_parser_lambda_introducer): Reject `&this'.  Use
	cp_lexer_nth_token_is instead of cp_lexer_peek_nth_token.

	* g++.dg/cpp0x/lambda/lambda-this21.C: New test.

From-SVN: r272223
2019-06-12 22:41:35 +00:00

11 lines
307 B
C

// PR c++/66999 - 'this' captured by reference.
// { dg-do compile { target c++11 } }
struct X {
void bar (int n)
{
auto l1 = [&this] { }; // { dg-error ".this. cannot be captured by reference" }
auto l2 = [=, &this] { }; // { dg-error ".this. cannot be captured by reference" }
}
};