[PATCH v2][RFC] Canonize names of attributes.

Martin Liška mliska@suse.cz
Thu Jul 13 13:48:00 GMT 2017


On 07/11/2017 05:52 PM, Jason Merrill wrote:
> On Tue, Jul 11, 2017 at 9:37 AM, Martin Liška <mliska@suse.cz> wrote:
>> On 07/03/2017 11:00 PM, Jason Merrill wrote:
>>> On Mon, Jul 3, 2017 at 5:52 AM, Martin Liška <mliska@suse.cz> wrote:
>>>> On 06/30/2017 09:34 PM, Jason Merrill wrote:
>>>>>
>>>>> On Fri, Jun 30, 2017 at 5:23 AM, Martin Liška <mliska@suse.cz> wrote:
>>>>>>
>>>>>> This is v2 of the patch, where just names of attributes are
>>>>>> canonicalized.
>>>>>> Patch can bootstrap on ppc64le-redhat-linux and survives regression
>>>>>> tests.
>>>>>
>>>>>
>>>>> What is the purpose of the new "strict" parameter to cmp_attribs* ?  I
>>>>> don't see any discussion of it.
>>>>
>>>>
>>>> It's needed for arguments of attribute names, like:
>>>>
>>>> /usr/include/stdio.h:391:62: internal compiler error: in cmp_attribs, at
>>>> tree.h:5523
>>>>        __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
>>>>
>>>
>>> Mm.  Although we don't want to automatically canonicalize all
>>> identifier arguments to attributes in the parser, we could still do it
>>> for specific attributes, e.g. in handle_format_attribute or
>>> handle_mode_attribute.
>>
>> Yep, that was done in my previous version of the patch
>> (https://gcc.gnu.org/ml/gcc-patches/2017-06/msg00996.html).
>> Where only attribute that was preserved unchanged was 'cleanup':
>>
>> diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
>> index 8f638785e0e..08b4db5e5bd 100644
>> --- a/gcc/cp/parser.c
>> +++ b/gcc/cp/parser.c
>> @@ -24765,7 +24765,8 @@ cp_parser_gnu_attribute_list (cp_parser* parser)
>>                   tree tv;
>>                   if (arguments != NULL_TREE
>>                       && ((tv = TREE_VALUE (arguments)) != NULL_TREE)
>> -                     && TREE_CODE (tv) == IDENTIFIER_NODE)
>> +                     && TREE_CODE (tv) == IDENTIFIER_NODE
>> +                     && !id_equal (TREE_PURPOSE (attribute), "cleanup"))
>>                     TREE_VALUE (arguments) = canonize_attr_name (tv);
>>                   release_tree_vector (vec);
>>                 }
>>
>> Does it work for you to do it so?
> 
> This is canonicalizing arguments by default; I want the default to be
> not canonicalizing arguments.  I think we only want to canonicalize
> arguments for format and mode, and we can do that in their handle_*
> functions.

Yep, done that in v3. I decided to move couple of functions to attribs.h and
verified that it will not cause binary size increase of cc1 and cc1plus.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

> 
> Jason
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Canonicalize-names-of-attributes-v3.patch
Type: text/x-patch
Size: 19654 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20170713/bd833c40/attachment.bin>


More information about the Gcc-patches mailing list