diff mbox series

c: support attribs starting with '_'

Message ID eea8eca0-6b5d-c5fa-e5bd-aa5409bd78c6@suse.cz
State New
Headers show
Series c: support attribs starting with '_' | expand

Commit Message

Martin Liška Oct. 5, 2022, 11:49 a.m. UTC
PR c/107156

gcc/ChangeLog:

	* attribs.h (lookup_attribute_by_prefix): Support attributes
	starting with underscore (like _noreturn, or __Noreturn).
---
 gcc/attribs.h | 2 --
 1 file changed, 2 deletions(-)

Comments

Jakub Jelinek Oct. 5, 2022, 12:01 p.m. UTC | #1
On Wed, Oct 05, 2022 at 01:49:40PM +0200, Martin Liška wrote:
> 	PR c/107156
> 
> gcc/ChangeLog:
> 
> 	* attribs.h (lookup_attribute_by_prefix): Support attributes
> 	starting with underscore (like _noreturn, or __Noreturn).

There are no _noreturn or __Noreturn attributes, there is just
_Noreturn.
And, the assert is useful to catch that non-canonicalized attributes
don't make it into the attribute lists.
Now that we have the first attribute that starts with an underscore
in canonicalized form (do we accept ___Noreturn__ attribute too, perhaps
we shouldn't?), I'd say instead of removing the assert it should verify
	gcc_checking_assert (attr_len == 0 || p[0] != '_'
			     || (ident_len > 1 && p[1] != '_'));
?
> ---
>  gcc/attribs.h | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/gcc/attribs.h b/gcc/attribs.h
> index b2836560fc2..706d35e63d8 100644
> --- a/gcc/attribs.h
> +++ b/gcc/attribs.h
> @@ -274,8 +274,6 @@ lookup_attribute_by_prefix (const char *attr_name, tree list)
>  	    }
>  
>  	  const char *p = IDENTIFIER_POINTER (name);
> -	  gcc_checking_assert (attr_len == 0 || p[0] != '_');
> -
>  	  if (strncmp (attr_name, p, attr_len) == 0)
>  	    break;
>  
> -- 
> 2.37.3

	Jakub
Martin Liška Oct. 5, 2022, 12:52 p.m. UTC | #2
On 10/5/22 14:01, Jakub Jelinek wrote:
> On Wed, Oct 05, 2022 at 01:49:40PM +0200, Martin Liška wrote:
>> 	PR c/107156
>>
>> gcc/ChangeLog:
>>
>> 	* attribs.h (lookup_attribute_by_prefix): Support attributes
>> 	starting with underscore (like _noreturn, or __Noreturn).
> 
> There are no _noreturn or __Noreturn attributes, there is just
> _Noreturn.
> And, the assert is useful to catch that non-canonicalized attributes
> don't make it into the attribute lists.
> Now that we have the first attribute that starts with an underscore
> in canonicalized form (do we accept ___Noreturn__ attribute too, perhaps
> we shouldn't?), I'd say instead of removing the assert it should verify
> 	gcc_checking_assert (attr_len == 0 || p[0] != '_'
> 			     || (ident_len > 1 && p[1] != '_'));

Works for me, I'm going to install the following patch.

Martin

> ?
>> ---
>>  gcc/attribs.h | 2 --
>>  1 file changed, 2 deletions(-)
>>
>> diff --git a/gcc/attribs.h b/gcc/attribs.h
>> index b2836560fc2..706d35e63d8 100644
>> --- a/gcc/attribs.h
>> +++ b/gcc/attribs.h
>> @@ -274,8 +274,6 @@ lookup_attribute_by_prefix (const char *attr_name, tree list)
>>  	    }
>>  
>>  	  const char *p = IDENTIFIER_POINTER (name);
>> -	  gcc_checking_assert (attr_len == 0 || p[0] != '_');
>> -
>>  	  if (strncmp (attr_name, p, attr_len) == 0)
>>  	    break;
>>  
>> -- 
>> 2.37.3
> 
> 	Jakub
>
diff mbox series

Patch

diff --git a/gcc/attribs.h b/gcc/attribs.h
index b2836560fc2..706d35e63d8 100644
--- a/gcc/attribs.h
+++ b/gcc/attribs.h
@@ -274,8 +274,6 @@  lookup_attribute_by_prefix (const char *attr_name, tree list)
 	    }
 
 	  const char *p = IDENTIFIER_POINTER (name);
-	  gcc_checking_assert (attr_len == 0 || p[0] != '_');
-
 	  if (strncmp (attr_name, p, attr_len) == 0)
 	    break;