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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-07-02
                 CC|                            |msebor at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
There is value in diagnosing the use of attributes that GCC doesn't know about.

According to the manual -Wattributes also sounds like the right option to
control warnings about unknown attributes.  Unfortunately, the option is also
used by GCC to control warnings about known attributes using in a way GCC
either doesn't consider valid or cannot honor and where -Wignored-attributes
might be more appropriate.  For example:

warning: ‘packed’ attribute ignored for field of type ‘char’ [-Wattributes]
 struct S { __attribute__ ((packed)) char c; };

Here, packed is used correctly but is "ignored" because it is implied on
members whose alignment is 8.  (It's ignored internally within GCC but that's
an implementation detail that's opaque to the user.  In this instance, I'd say
the warning should not be issued.)

Similarly for:

__attribute__ ((always_inline)) inline void f (void);

__attribute ((noinline)) void f (void);

warning: ignoring attribute ‘noinline’ because it conflicts with attribute
‘always_inline’ [-Wattributes]
 __attribute ((noinline)) void f (void);

where there's nothing wrong with either attribute but GCC can only honor one
and has to ignore the other.  Here, the warning is useful but distinct in
nature from an unknown attribute (like the one on bug 86243).

IMO, it should be possible to control warnings about attributes unknown to GCC
independently of other warnings about uses of known attributes.  Thus
confirmed.

Reply via email to