[PATCH] Switching attribute warning diagnostic groups

Richard Smith richard at metafoo.co.uk
Thu Jan 23 13:11:06 PST 2014


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.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140123/1aa9cef4/attachment.html>


More information about the cfe-commits mailing list