[PATCH] handle attribute positional arguments consistently (PR 87541, 87542)

Martin Sebor msebor@gmail.com
Tue Oct 9 05:11:00 GMT 2018


Attached is an updated patch with the INTEGRAL_TYPE_P test added
to detect constant non-integer arguments like (void*)0, and with
quoting made unconditional.  I also removed the pretty printer
business to avoid the "value%s" format, and modified the manual
to clarify when each of the attributes are applicable and what
their meaningful argument values are.

On 10/07/2018 04:38 PM, Martin Sebor wrote:
> While still testing an enhancement in the area of attributes
> I ran across bugs and inconsistencies in how different handlers
> deal with positional arguments.  The bugs are either an ICE due
> to the handlers not consistently converting positional arguments
> to constants (i.e., CONST_DEL to INTEGER_CST in C++) for which
> downstream code is unprepared (PR 87541), or errors for valid
> code (PR 87542), or failing to diagnose invalid arguments.
> The other inconsistencies are simply in responding to the same
> invalid condition differently for different attributes .
>
> The attached patch introduces a new function to do validate
> positional arguments in a uniform way and replaces the existing
> handling with it.
>
> As a consequence of the handling being made consistent a number
> of tests needed adjusting. In addition, some invalid arguments
> that were previously rejected with a hard error are diagnosed
> with just a warning (invalid argument values in attribute format),
> and in one other instance what previously triggered a warning is
> now accepted without one (attribute alloc_size on a function
> without a prototype).  I'd be up tightening things up if that's
> preferable as long it's done consistently.
>
> Tested on x86_64-linux.
>
> Martin
>
> PS It would be nice to have a general policy for how to respond
> to invalid attribute arguments (warning or error).  Even better,
> it would be ideal to move the validation from the front-ends and
> back-ends into the middle-end.  I.e., describe attribute arguments
> in more detail in struct attribute_spec and have decl_attributes
> validate nut just the number of arguments but also their types
> and, when appropriate, expected values.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-87541.diff
Type: text/x-patch
Size: 62656 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20181009/62670f03/attachment.bin>


More information about the Gcc-patches mailing list