On 02/02/2018 11:58 AM, Martin Sebor wrote: > The design of the attribute exclusion framework includes > support for different exclusions applying to different > kinds of declarations (functions, types, and variables > or fields), but the support is incomplete -- the logic > to consider these differences is missing. This is > because the differences are apparently rare. However, > as the bug below points out, they do exist. > > PR middle-end/84108 - incorrect -Wattributes warning for > packed/aligned conflict on struct members, shows that while > declaring a non-member variable aligned is enough to reduce > the its alignment and declaring it both aligned and packed > triggers a -Wattributes warning: > > int a __attribute__((packed, aligned (2))); // -Wattributes > > a struct member must be declared both aligned and packed in > order to have its alignment reduced. (Declaring a member > just aligned has no effect and doesn't cause a warning). > > struct S { > int b __attribute__((packed, aligned (2))); > int c __attribute__((aligned (2))); // no effect > }; > > As a result of the incomplete logic GCC 8 issues a -Wattributes > for the declaration of b in the struct. > > By adding the missing logic the attached patch lets GCC avoid > the spurious warning. > > I considered adding support for detecting the ineffective > attribute aligned on the declaration of the member c at > the same time but since that's not a regression I decided > to defer that until GCC 9. I opened bug 84185 to track it. > > Tested on x86_64-linux with no regressions. > > Martin > > gcc-84108.diff > > > PR middle-end/84108 - incorrect -Wattributes warning for packed/aligned > conflict on struct members > > gcc/ChangeLog: > > PR c/84108 > * attribs.c (diag_attr_exclusions): Consider the exclusion(s) > that correspond to the kind of a declaration. > > gcc/testsuite/ChangeLog: > > PR c/84108 > * gcc.dg/Wattributes-8.c: New test. OK. Sorry for the wait.
Thanks. Jeff