Message ID | 20200422205737.GR2424@tucnak |
---|---|
State | New |
Headers | show |
Series | attribs: Don't diagnose attribute exclusions during error recovery [PR94705] | expand |
On Wed, 22 Apr 2020, Jakub Jelinek wrote: > Hi! > > 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). > > Bootstrapped/regtested on powerpc64{,le}-linux, ok for trunk? OK. > 2020-04-22 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. > > --- gcc/attribs.c.jj 2020-01-15 00:26:26.444529132 +0100 > +++ gcc/attribs.c 2020-04-22 10:12:49.071442463 +0200 > @@ -677,7 +677,8 @@ decl_attributes (tree *node, tree attrib > 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. > --- gcc/testsuite/gcc.dg/pr94705.c.jj 2020-04-22 10:18:13.491485751 +0200 > +++ gcc/testsuite/gcc.dg/pr94705.c 2020-04-22 10:19:06.077682332 +0200 > @@ -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); > +} > > Jakub > >
--- gcc/attribs.c.jj 2020-01-15 00:26:26.444529132 +0100 +++ gcc/attribs.c 2020-04-22 10:12:49.071442463 +0200 @@ -677,7 +677,8 @@ decl_attributes (tree *node, tree attrib 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. --- gcc/testsuite/gcc.dg/pr94705.c.jj 2020-04-22 10:18:13.491485751 +0200 +++ gcc/testsuite/gcc.dg/pr94705.c 2020-04-22 10:19:06.077682332 +0200 @@ -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); +}