PR c++/96437: ICE-on-invalid-code error recovery.

This patch fixes PR c++/96437 which is an ICE-on-invalid-code regression
affecting mainline.

2022-03-08  Roger Sayle  <roger@nextmovesoftware.com>

gcc/cp/ChangeLog
	PR c++/96437
	* parser.cc (synthesize_implicit_template_parm): Check that
	TREE_VALUE (new_parm) isn't error_mark_node before setting its
	DECL_VIRTUAL_P.

gcc/testsuite/ChangeLog
	PR c++/96437
	* g++.dg/cpp2a/pr96437.C: New test case.
This commit is contained in:
Roger Sayle 2022-03-08 23:23:19 +00:00
parent 8ab72ec7c4
commit 3093f8a18e
2 changed files with 6 additions and 1 deletions

View File

@ -48218,7 +48218,8 @@ synthesize_implicit_template_parm (cp_parser *parser, tree constr)
function template is equivalent to an explicit template.
Note that DECL_ARTIFICIAL is used elsewhere for template parameters. */
DECL_VIRTUAL_P (TREE_VALUE (new_parm)) = true;
if (TREE_VALUE (new_parm) != error_mark_node)
DECL_VIRTUAL_P (TREE_VALUE (new_parm)) = true;
// Chain the new parameter to the list of implicit parameters.
if (parser->implicit_template_parms)

View File

@ -0,0 +1,4 @@
/* { dg-do compile } */
/* { dg-excess-errors "" } */
template <()> void A(auto){}