public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-8-branch)] attribs: Don't diagnose attribute exclusions during error recovery [PR94705]
@ 2020-09-17 17:22 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 17:22 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:19be15e11849ab0e8587fb03f5da86fe51a176dc
commit 19be15e11849ab0e8587fb03f5da86fe51a176dc
Author: Jakub Jelinek <jakub@redhat.com>
Date: Thu Apr 23 09:54:14 2020 +0200
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 <jakub@redhat.com>
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.
(cherry picked from commit e2a71816b4949225498bec37e947293aa7f5841b)
Diff:
---
gcc/attribs.c | 3 ++-
gcc/testsuite/gcc.dg/pr94705.c | 13 +++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/gcc/attribs.c b/gcc/attribs.c
index fc21f799d92..4db4052ec15 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -702,7 +702,8 @@ decl_attributes (tree *node, tree attributes, int flags,
bool built_in = flags & ATTR_FLAG_BUILT_IN;
if (spec->exclude
&& !no_add_attrs
- && (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/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);
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-17 17:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 17:22 [gcc(refs/vendors/redhat/heads/gcc-8-branch)] attribs: Don't diagnose attribute exclusions during error recovery [PR94705] Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).