From: Roger Sayle Date: Tue, 8 Mar 2022 23:23:19 +0000 (+0000) Subject: PR c++/96437: ICE-on-invalid-code error recovery. X-Git-Tag: upstream/12.2.0~1147 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3093f8a18e7a9c5a9bba976d58a2f91033e7f35a;p=platform%2Fupstream%2Fgcc.git 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 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. --- diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index dc2d39a..9153c74 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -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) diff --git a/gcc/testsuite/g++.dg/cpp2a/pr96437.C b/gcc/testsuite/g++.dg/cpp2a/pr96437.C new file mode 100644 index 0000000..79d481e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/pr96437.C @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-excess-errors "" } */ + +template <()> void A(auto){}