diff mbox

[v2,RFC] Canonize names of attributes.

Message ID 669c960e-f4a8-eae3-efd2-f8c29477a817@suse.cz
State New
Headers show

Commit Message

Martin Liška July 11, 2017, 1:37 p.m. UTC
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':


Does it work for you to do it so?

Martin

> 
> Jason
>

Comments

Jason Merrill July 11, 2017, 3:52 p.m. UTC | #1
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.

Jason
diff mbox

Patch

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);
  		}