]> gcc.gnu.org Git - gcc.git/commit
c: ICE on invalid with attribute optimize [PR115549]
authorMarek Polacek <polacek@redhat.com>
Thu, 27 Jun 2024 20:39:29 +0000 (16:39 -0400)
committerMarek Polacek <polacek@redhat.com>
Wed, 10 Jul 2024 18:37:54 +0000 (14:37 -0400)
commit4c7009735f73f59c9a635d79c048c8981310e331
tree39b2d1e10439f48566f4b221e1dd7ac68f392d5a
parent4865a92b35054fdfaa1318a4c1f56d95d44012a2
c: ICE on invalid with attribute optimize [PR115549]

I had this PR in my open tabs so why not go ahead and fix it.

decl_attributes gets last_decl, the last already pushed declaration,
to be used in common_handle_aligned_attribute.  In C++, we look up
the decl via find_last_decl, which returns NULL_TREE if it finds
a decl that had not been declared.  In C, we look up the decl via
lookup_last_decl which returns error_mark_node rather than NULL_TREE
in that case.

The error_mark_node causes a crash in common_handle_aligned_attribute.
We can fix this on the C FE side like in the patch below.

PR c/115549

gcc/c/ChangeLog:

* c-decl.cc (c_decl_attributes): If lookup_last_decl returns
error_mark_node, use NULL_TREE as last_decl.

gcc/testsuite/ChangeLog:

* c-c++-common/attr-aligned-2.c: New test.
gcc/c/c-decl.cc
gcc/testsuite/c-c++-common/attr-aligned-2.c [new file with mode: 0644]
This page took 0.063407 seconds and 5 git commands to generate.