c++: fix ICE on invalid attributes [PR96637]
authorMarek Polacek <polacek@redhat.com>
Thu, 28 Apr 2022 17:21:41 +0000 (13:21 -0400)
committerMarek Polacek <polacek@redhat.com>
Wed, 25 May 2022 20:13:45 +0000 (16:13 -0400)
commitda2c56ee601ac696a76e469e33c88313428c5c5a
tree4d6279b55c6c7652e918d41ea47843cebc76710b
parent34970d08c6297e12f3f9117b6ac19fb2de522e24
c++: fix ICE on invalid attributes [PR96637]

When chaining attributes, attr_chainon should be used rather than plain
chainon, so that we don't end up with a TREE_LIST where one of the elements
is error_mark_node, which causes problems.  parser.cc has already been
fixed to use attr_chainon, but decl.cc has not.  Until now.

PR c++/96637

gcc/cp/ChangeLog:

* cp-tree.h (attr_chainon): Declare.
* decl.cc (start_decl): Use attr_chainon.
(grokdeclarator): Likewise.
* parser.cc (cp_parser_statement): No longer static.

gcc/testsuite/ChangeLog:

* g++.dg/parse/error64.C: New test.
gcc/cp/cp-tree.h
gcc/cp/decl.cc
gcc/cp/parser.cc
gcc/testsuite/g++.dg/parse/error64.C [new file with mode: 0644]