[PATCH] Switching attribute warning diagnostic groups

Aaron Ballman aaron at aaronballman.com
Fri Jan 24 06:22:10 PST 2014


Good idea! I've commit in r200004.

~Aaron

On Thu, Jan 23, 2014 at 4:11 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> On Thu, Jan 23, 2014 at 9:35 AM, Aaron Ballman <aaron at aaronballman.com>
> wrote:
>>
>> PR4860 points out an inconsistency with how clang behaves compared to
>> gcc in terms of -Wno-attributes. GCC's documentation says
>> (http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html):
>>
>> -Wno-attributesDo not warn if an unexpected __attribute__ is used,
>> such as unrecognized attributes, function attributes applied to
>> variables, etc. This does not stop errors for incorrect use of
>> supported attributes.
>>
>> While I personally find it bizarre that "function attributes applied
>> to variables" is not an example of "incorrect use of supported
>> attributes", it turns out that GCC really honors this.
>>
>> __attribute__((__warn_unused_result__)) int x;
>>
>> When compiled with -Wno-attributes does not warn in gcc, but does
>> currently warn in clang. This patch addresses that, but since it's
>> switching diagnostic groups, I figured it might warrant a bit of
>> discussion.
>
>
> I don't think the GCC position of differentiating "incorrect use of
> supported attributes" from "attributes applied to the wrong kind of entity"
> makes much sense. Having taken a brief look over our -Wignored-attributes
> warning, I have a slightly different suggestion:
>
> Rename the UnknownAttributes group to -Wunknown-attributes, and add a new
> -Wattributes group containing both IgnoredAttributes and UnknownAttributes.
> (That is, make -Wignored-attributes continue to be "we know what this
> attribute name means, but it didn't apply here", make -Wunknown-attributes
> continue to be "we don't know what this attribute name means", and make
> -Wattributes cover both.)



More information about the cfe-commits mailing list