re PR c++/59629 ([c++11] ICE with invalid use of auto in lambda function)

Fix PR c++/59629

	PR c++/59629
	* cp/parser.c (cp_parser_lambda_expression): Save/reset/restore
	auto_is_implicit_function_template_parm_p around lambda body.

	* g++.dg/cpp1y/pr59629.C: New testcase.

From-SVN: r206370
This commit is contained in:
Adam Butcher 2014-01-06 18:22:38 +00:00 committed by Adam Butcher
parent 81fdaa176d
commit 2418d7da3a
4 changed files with 18 additions and 0 deletions

View File

@ -8,6 +8,10 @@
* cp/parser.c (cp_parser_template_parameter): Early out with
error_mark_node if parameter declaration was not parsed.
PR c++/59629
* cp/parser.c (cp_parser_lambda_expression): Save/reset/restore
auto_is_implicit_function_template_parm_p around lambda body.
2014-01-03 Marc Glisse <marc.glisse@inria.fr>
PR c++/58950

View File

@ -8738,6 +8738,8 @@ cp_parser_lambda_expression (cp_parser* parser)
= parser->fully_implicit_function_template_p;
tree implicit_template_parms = parser->implicit_template_parms;
cp_binding_level* implicit_template_scope = parser->implicit_template_scope;
bool auto_is_implicit_function_template_parm_p
= parser->auto_is_implicit_function_template_parm_p;
parser->num_template_parameter_lists = 0;
parser->in_statement = 0;
@ -8745,6 +8747,7 @@ cp_parser_lambda_expression (cp_parser* parser)
parser->fully_implicit_function_template_p = false;
parser->implicit_template_parms = 0;
parser->implicit_template_scope = 0;
parser->auto_is_implicit_function_template_parm_p = false;
/* By virtue of defining a local class, a lambda expression has access to
the private variables of enclosing classes. */
@ -8772,6 +8775,8 @@ cp_parser_lambda_expression (cp_parser* parser)
= fully_implicit_function_template_p;
parser->implicit_template_parms = implicit_template_parms;
parser->implicit_template_scope = implicit_template_scope;
parser->auto_is_implicit_function_template_parm_p
= auto_is_implicit_function_template_parm_p;
}
pop_deferring_access_checks ();

View File

@ -2,8 +2,10 @@
PR c++/59635
PR c++/59636
PR c++/59629
* g++.dg/cpp1y/pr59635.C: New testcase.
* g++.dg/cpp1y/pr59636.C: New testcase.
* g++.dg/cpp1y/pr59629.C: New testcase.
2014-01-06 Martin Jambor <mjambor@suse.cz>

View File

@ -0,0 +1,7 @@
// { dg-do compile }
// { dg-options "-std=c++1y" }
// PR c++/59629
void foo(int i = []{ auto 0; }()); // { dg-error "expected|could not convert" }