This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] avoid -Wsuggest-attribute=const for void functions (PR 83559)


On 01/01/2018 05:50 PM, Martin Sebor wrote:
> Among the recent -Wattributes enhancements is to diagnose
> declarations of void functions with attribute const or pure.
> Declaring a void function const or pure means that calls to
> the function have no effect and could be (and, with
> optimization, are) eliminated.  Thus the attribute on such
> a function would imply that either the function is useless
> or the attribute is (when the function is called inidirectly).
> 
> As it happens, however, -Wsuggest-attribute=const suggests
> adding the const attribute to candidate functions that return
> void, thus causing a conflict between the two options.
> 
> The attached patch resolves the conflict by avoiding
> -Wsuggest-attribute=const for void functions.
> 
> Martin
> 
> gcc-83559.diff
> 
> 
> PR c/83559 - -Wsuggest-attribute=const conflicts with -Wattributes warning about const attribute on function returning void
> 
> gcc/ChangeLog:
> 
> 	PR c/83559
> 	* doc/extend.texi (attribute const): Fix a typo.
> 	* ipa-pure-const.c ((warn_function_const, warn_function_pure): Avoid
> 	issuing -Wsuggest-attribute for void functions.
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR c/83559
> 	* gcc.dg/const-2.c: New test.
> 	* gcc.dg/pure-3.c: New test.
OK

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]