This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][RFC] Canonize names of attributes.
On 06/14/2017 06:40 PM, Joseph Myers wrote:
> On Wed, 14 Jun 2017, Richard Biener wrote:
>
>>>> are you sure this is needed? This seems to be solely arguments to
>>>> attributes.
>>>
>>> It's need for cases like:
>>> __intN_t (8, __QI__);
>>
>> But __QI__ is not processed in lookup_attribute, is it? So canonizing that
>> looks unrelated? I didn't see similar handling in the C FE btw (but
>> maybe I missed it).
>
> It's not clear to me that there is automatically a rule that where
> identifiers are arguments to attributes, they must follow this rule about
> foo and __foo__ being equivalent.
>
> Specifically: c-attribs.c:attribute_takes_identifier_p says that the
> cleanup attribute takes an identifier (a function name). But it's
> certainly the case that the exact function named there must be used; foo
> and __foo__ as cleanup attribute arguments are not equivalent. (You could
> argue cleanup should take an expression, with an error then being given if
> that doesn't evaluate to a function designator.)
>
Hello.
This is obvious reason where original name must be preserved. Looks following patch
works and does not break test-suite:
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);
}
--
Well, the question is whether we want to in general canonicalize attribute names?
Special situations like "cleanup" can be handled.
Martin