Fix PR c++/70218 (illegal access to private field succeeds)

gcc/cp/ChangeLog:

	PR c++/70218
	* parser.c (cp_parser_lambda_expression): Move call to
	pop_deferring_access_checks ahead of the call to
	cp_parser_end_tentative_firewall.

gcc/testsuite/ChangeLog:

	PR c++/70218
	* g++.dg/cpp0x/lambda/lambda-70218.C: New test.

From-SVN: r234316
This commit is contained in:
Patrick Palka 2016-03-18 01:23:26 +00:00
parent 4a8e35b32c
commit 753a8910a4
4 changed files with 31 additions and 2 deletions

View File

@ -1,3 +1,10 @@
2016-03-18 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/70218
* parser.c (cp_parser_lambda_expression): Move call to
pop_deferring_access_checks ahead of the call to
cp_parser_end_tentative_firewall.
2016-03-17 Jakub Jelinek <jakub@redhat.com>
PR c++/70144

View File

@ -9781,8 +9781,6 @@ cp_parser_lambda_expression (cp_parser* parser)
= auto_is_implicit_function_template_parm_p;
}
pop_deferring_access_checks ();
/* This field is only used during parsing of the lambda. */
LAMBDA_EXPR_THIS_CAPTURE (lambda_expr) = NULL_TREE;
@ -9798,6 +9796,8 @@ cp_parser_lambda_expression (cp_parser* parser)
cp_parser_end_tentative_firewall (parser, start, lambda_expr);
pop_deferring_access_checks ();
return lambda_expr;
}

View File

@ -1,3 +1,8 @@
2016-03-18 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/70218
* g++.dg/cpp0x/lambda/lambda-70218.C: New test.
2016-03-17 Marek Polacek <polacek@redhat.com>
PR c/69407

View File

@ -0,0 +1,17 @@
// PR c++/70218
// { dg-do compile { target c++11 } }
struct X {
private:
int i;
};
struct Y {
Y (int) { }
};
void
foo ()
{
Y ([] { X x; x.i = 3; return 0; } ()); // { dg-error "private" }
}