From: Jakub Jelinek Date: Thu, 23 Apr 2020 07:54:14 +0000 (+0200) Subject: attribs: Don't diagnose attribute exclusions during error recovery [PR94705] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e2a71816b4949225498bec37e947293aa7f5841b;p=gcc.git attribs: Don't diagnose attribute exclusions during error recovery [PR94705] On the following testcase GCC ICEs, because last_decl is error_mark_node, and diag_attr_exclusions assumes that if it is not NULL, it must be a decl. The following patch just doesn't diagnose attribute exclusions if the other decl is erroneous (and thus we've already reported errors for it). 2020-04-23 Jakub Jelinek PR c/94705 * attribs.c (decl_attribute): Don't diagnose attribute exclusions if last_decl is error_mark_node or has such a TREE_TYPE. * gcc.dg/pr94705.c: New test. --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 085135c7a08..06f7eda0033 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-04-23 Jakub Jelinek + + PR c/94705 + * attribs.c (decl_attribute): Don't diagnose attribute exclusions + if last_decl is error_mark_node or has such a TREE_TYPE. + 2020-04-22 Felix Yang PR target/94678 diff --git a/gcc/attribs.c b/gcc/attribs.c index c66d4ae2c06..7d0f4b5b7b4 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -677,7 +677,8 @@ decl_attributes (tree *node, tree attributes, int flags, reject incompatible attributes. */ bool built_in = flags & ATTR_FLAG_BUILT_IN; if (spec->exclude - && (flag_checking || !built_in)) + && (flag_checking || !built_in) + && !error_operand_p (last_decl)) { /* Always check attributes on user-defined functions. Check them on built-ins only when -fchecking is set. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1115eb76968..684e408c1a5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-04-23 Jakub Jelinek + + PR c/94705 + * gcc.dg/pr94705.c: New test. + 2020-04-22 Patrick Palka PR c++/94719 diff --git a/gcc/testsuite/gcc.dg/pr94705.c b/gcc/testsuite/gcc.dg/pr94705.c new file mode 100644 index 00000000000..96392ab60ee --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr94705.c @@ -0,0 +1,13 @@ +/* PR c/94705 */ +/* { dg-do compile } */ +/* { dg-options "" } */ + +void foo (); + +int +bar (void) +{ + foo (baz); /* { dg-error "'baz' undeclared" } */ + /* { dg-message "only once" "" { target *-*-* } .-1 } */ + void __attribute__ ((noinline)) baz (void); +}