public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c: support attribs starting with '_'
@ 2022-10-05 11:42 Martin Liška
  2022-10-05 11:48 ` Andreas Schwab
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Liška @ 2022-10-05 11:42 UTC (permalink / raw)
  To: gcc-patches

Support attributes starting with dash (like _noreturn, or __Noreturn).
Note the only consumer of lookup_attribute_by_prefix comes from IPA ICF.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

	PR c/107156

gcc/ChangeLog:

	* attribs.h (lookup_attribute_by_prefix): Support attributes
	starting with dash (like _noreturn, or __Noreturn).
---
 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] c: support attribs starting with '_'
  2022-10-05 11:42 [PATCH] c: support attribs starting with '_' Martin Liška
@ 2022-10-05 11:48 ` Andreas Schwab
  2022-10-05 11:49   ` Martin Liška
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2022-10-05 11:48 UTC (permalink / raw)
  To: Martin Liška; +Cc: gcc-patches

On Okt 05 2022, Martin Liška wrote:

> 	* attribs.h (lookup_attribute_by_prefix): Support attributes
> 	starting with dash (like _noreturn, or __Noreturn).

s/dash/underscore/

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] c: support attribs starting with '_'
  2022-10-05 11:48 ` Andreas Schwab
@ 2022-10-05 11:49   ` Martin Liška
  2022-10-05 12:01     ` Jakub Jelinek
  0 siblings, 1 reply; 5+ messages in thread
From: Martin Liška @ 2022-10-05 11:49 UTC (permalink / raw)
  To: gcc-patches

	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(-)

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] c: support attribs starting with '_'
  2022-10-05 11:49   ` Martin Liška
@ 2022-10-05 12:01     ` Jakub Jelinek
  2022-10-05 12:52       ` Martin Liška
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2022-10-05 12:01 UTC (permalink / raw)
  To: Martin Liška; +Cc: gcc-patches

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] c: support attribs starting with '_'
  2022-10-05 12:01     ` Jakub Jelinek
@ 2022-10-05 12:52       ` Martin Liška
  0 siblings, 0 replies; 5+ messages in thread
From: Martin Liška @ 2022-10-05 12:52 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1374 bytes --]

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
> 

[-- Attachment #2: 0001-c-support-the-attribute-starting-with-_.patch --]
[-- Type: text/x-patch, Size: 910 bytes --]

From b7eb1e7a0e887849470ec96c5f31422b2224c461 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Wed, 5 Oct 2022 12:34:30 +0200
Subject: [PATCH] c: support the attribute starting with '_'

	PR c/107156

gcc/ChangeLog:

	* attribs.h (lookup_attribute_by_prefix): Support the attribute
	starting with underscore (_Noreturn).
---
 gcc/attribs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-10-05 12:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-05 11:42 [PATCH] c: support attribs starting with '_' Martin Liška
2022-10-05 11:48 ` Andreas Schwab
2022-10-05 11:49   ` Martin Liška
2022-10-05 12:01     ` Jakub Jelinek
2022-10-05 12:52       ` Martin Liška

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).