c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes...
authorJakub Jelinek <jakub@redhat.com>
Wed, 6 Apr 2022 15:53:41 +0000 (17:53 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 6 Apr 2022 15:53:41 +0000 (17:53 +0200)
commit9fd377a747375a82912bd81c67b275301489785c
treeaab45ae8bb44b7ee3f02e9f5f61bc51825379af6
parente58484a019c57b1085bbbcc1654f1944feddfe73
c++: Fix up ICE when cplus_decl_attributes is called with error_mark_node attributes [PR104668]

cplus_decl_attributes can be called with attributes equal to
error_mark_node, there are some spots in the function that test
it or decl_attributes it calls starts with:
  if (TREE_TYPE (*node) == error_mark_node || attributes == error_mark_node)
    return NULL_TREE;
But the recent PR104245 change broke this when processing_template_decl
is true.

The patch returns early for attributes error_mark_node from
cplus_decl_attributes.

2022-04-06  Jakub Jelinek  <jakub@redhat.com>

PR c++/104668
* decl2.cc (splice_template_attributes): Return NULL if *p is
error_mark_node.
(cplus_decl_attributes): Return early if attributes is
error_mark_node.  Don't check that later.

* g++.dg/cpp0x/pr104668.C: New test.
gcc/cp/decl2.cc
gcc/testsuite/g++.dg/cpp0x/pr104668.C [new file with mode: 0644]