https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103056

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |diagnostic
   Last reconfirmed|                            |2021-11-03
     Ever confirmed|0                           |1
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
I don't think -Wignored-attributes was ever meant to suppress errors for
invalid specifications of known attributes.  The documentation sounds like it
should but the change that introduced it, r234433, makes it clear that the
option's effect is limited to just a single C++ warning.  Below is a test case
showing errors for other attributes that can't be suppressed by the either
option.

At a minimum, the documentation of the option should be updated to reflect that
(i.e., that it's a C++ warning for templates).  At the same time, having just
one option (-Wattributes) control all aspects of attribute validation isn't
good enough as users have occasionally asked for finer-grained control.  So it
might be useful to extend -Wignored-attributes to other attributes and
situations (and to C as well).

So confirmed.

$ cat pr103056.c && gcc -S -Wall -Wno-attributes -Wno-ignored-attributes
pr103056.c
__attribute__ ((access (none, 1))) int foo (const void *);

__attribute__ ((alias ("foo"))) int bar (const void *);
__attribute__ ((weakref)) int bar (const void *);

void baz (void)
{
  int i __attribute__ ((section ("foobar"))) = 0;
  (void)&i;
}
pr103056.c:1:1: error: attribute ‘access’ invalid mode ‘none’; expected one of
‘read_only’, ‘read_write’, or ‘write_only’
    1 | __attribute__ ((access (none, 1))) int foo (const void *);
      | ^~~~~~~~~~~~~
pr103056.c:3:37: error: ‘weakref’ symbol ‘bar’ must have static linkage
    3 | __attribute__ ((alias ("foo"))) int bar (const void *);
      |                                     ^~~
pr103056.c: In function ‘baz’:
pr103056.c:8:7: error: section attribute cannot be specified for local
variables
    8 |   int i __attribute__ ((section ("foobar"))) = 0;
      |       ^

Reply via email to