Re: [RFC] Support for nonzero attribute

2022-06-13 Thread Martin Sebor via Gcc
On 6/13/22 06:55, Miika via Gcc wrote: Thank you for the feedback! On Sunday, June 12th, 2022 at 7:25 AM, Prathamesh Kulkarni wrote: On Mon, 6 Jun 2022 at 01:39, Miika via Gcc gcc@gcc.gnu.org wrote: Based on Jakub's and Yair's comments I created a new attribute "inrange". Inrage takes three

[RFC] Support for nonzero attribute

2022-06-13 Thread Miika via Gcc
Thank you for the feedback! On Sunday, June 12th, 2022 at 7:25 AM, Prathamesh Kulkarni wrote: > On Mon, 6 Jun 2022 at 01:39, Miika via Gcc gcc@gcc.gnu.org wrote: > > > Based on Jakub's and Yair's comments I created a new attribute "inrange". > > Inrage takes three arguments, pos min and max. > >

Re: [RFC] Support for nonzero attribute

2022-06-13 Thread Richard Biener via Gcc
ue(+20), nonZero) > > I do recall that few other languages had similar abilities (Ada, Java (via > annotations), ...) > > Yair > > > > > > > > > > ------ Forwarded message -- > > From: Miika > > To: "gcc@gcc.gnu.org" > > Cc: > &g

Re: [RFC] Support for nonzero attribute

2022-06-11 Thread Prathamesh Kulkarni via Gcc
On Mon, 6 Jun 2022 at 01:39, Miika via Gcc wrote: > > Based on Jakub's and Yair's comments I created a new attribute "inrange". > Inrage takes three arguments, pos min and max. > Pos being the argument position in the function, and min and max defines the > range of valid integer. Both min and max

Re: [RFC] Support for nonzero attribute

2022-06-09 Thread Miika via Gcc
On Thursday, June 9th, 2022 at 7:36 AM, Eric Gallager wrote: > Nice, good to hear! I'm looking forward to seeing this get added! I'll write some tests and try to send the patches next week! Miika

Re: [RFC] Support for nonzero attribute

2022-06-08 Thread Eric Gallager via Gcc
On Wed, Jun 8, 2022 at 5:00 PM Miika wrote: > > On Wednesday, June 8th, 2022 at 8:42 PM, Eric Gallager > wrote: > > Could you take a look at bug 78155 too? There was a request to add > > something like this in that bug: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78155 > > (and I think I've

[RFC] Support for nonzero attribute

2022-06-08 Thread Miika via Gcc
On Wednesday, June 8th, 2022 at 8:42 PM, Eric Gallager wrote: > Could you take a look at bug 78155 too? There was a request to add > something like this in that bug: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78155 > (and I think I've seen similar requests elsewhere, too) I took a look at th

Re: [RFC] Support for nonzero attribute

2022-06-08 Thread Eric Gallager via Gcc
On Sun, Jun 5, 2022 at 4:10 PM Miika via Gcc wrote: > > Based on Jakub's and Yair's comments I created a new attribute "inrange". > Inrage takes three arguments, pos min and max. > Pos being the argument position in the function, and min and max defines the > range of valid integer. Both min and m

[RFC] Support for nonzero attribute (Miika)

2022-06-08 Thread Yair Lenga via Gcc
Miika - lot of thanks. In .y mind, this is a major improvement. Also, want to suggest taking a nother look into the semnatic. I agreed inrange should include the low and high, similar to the gcc extensions) .. operator, the SQL in operator, perl .. operator, etc. There is another use common use c

[RFC] Support for nonzero attribute

2022-06-07 Thread Miika via Gcc
On Tuesday, June 7th, 2022 at 10:46 PM, Jonathan Wakely wrote: > On Tue, 7 Jun 2022 at 20:44, Jonathan Wakely wrote: > > > On Tue, 7 Jun 2022 at 20:40, Miika via Gcc gcc@gcc.gnu.org wrote: > > > > > On Monday, June 6th, 2022 at 9:42 PM, Ben Boeckel ben.boec...@kitware.com > > > wrote: > > > > >

Re: [RFC] Support for nonzero attribute

2022-06-07 Thread Jonathan Wakely via Gcc
On Tue, 7 Jun 2022 at 20:44, Jonathan Wakely wrote: > > On Tue, 7 Jun 2022 at 20:40, Miika via Gcc wrote: > > > > On Monday, June 6th, 2022 at 9:42 PM, Ben Boeckel > > wrote: > > > > Based on Jakub's and Yair's comments I created a new attribute > > > > "inrange". > > > > Inrage takes three arg

Re: [RFC] Support for nonzero attribute

2022-06-07 Thread Jonathan Wakely via Gcc
On Tue, 7 Jun 2022 at 20:40, Miika via Gcc wrote: > > On Monday, June 6th, 2022 at 9:42 PM, Ben Boeckel > wrote: > > > Based on Jakub's and Yair's comments I created a new attribute "inrange". > > > Inrage takes three arguments, pos min and max. > > > Pos being the argument position in the funct

[RFC] Support for nonzero attribute

2022-06-07 Thread Miika via Gcc
On Monday, June 6th, 2022 at 9:42 PM, Ben Boeckel wrote: > > Based on Jakub's and Yair's comments I created a new attribute "inrange". > > Inrage takes three arguments, pos min and max. > > Pos being the argument position in the function, and min and max defines the > > range of valid integer. Bo

Re: [RFC] Support for nonzero attribute

2022-06-06 Thread Ben Boeckel via Gcc
On Sun, Jun 05, 2022 at 20:09:04 +, Miika via Gcc wrote: > Based on Jakub's and Yair's comments I created a new attribute "inrange". > Inrage takes three arguments, pos min and max. > Pos being the argument position in the function, and min and max defines the > range of valid integer. Both min

[RFC] Support for nonzero attribute

2022-06-05 Thread Miika via Gcc
Based on Jakub's and Yair's comments I created a new attribute "inrange". Inrage takes three arguments, pos min and max. Pos being the argument position in the function, and min and max defines the range of valid integer. Both min and max are inclusive and work with enums. Warnings are enabled with

Re: [RFC] Support for nonzero attribute

2022-06-04 Thread Yair Lenga via Gcc
Static checks will be a good starting point! On Sat, Jun 4, 2022 at 7:55 AM Miika wrote: > On Saturday, June 4th, 2022 at 1:26 PM, Yair Lenga via Gcc < > gcc@gcc.gnu.org> wrote: > > The specific non-zero constraint is a specific implementation of the > range > > operator (with some exception see

[RFC] Support for nonzero attribute

2022-06-04 Thread Miika via Gcc
On Saturday, June 4th, 2022 at 1:26 PM, Yair Lenga via Gcc wrote: > The specific non-zero constraint is a specific implementation of the range > operator (with some exception see below). Wanted to suggest going for > more ambitious goal: add min and max attributes to (integer) types and > variabl

[RFC] Support for nonzero attribute

2022-06-04 Thread Miika via Gcc
Thank you for the feedback! On Friday, June 3rd, 2022 at 7:45 PM, Jakub Jelinek wrote: > For some functions, 0 could be a value it wants to avoid, for others > such value could be -1, negative value, positive, whatever else... > IMHO if we want to add anything like this, it should be more generic

[RFC] Support for nonzero attribute

2022-06-04 Thread Yair Lenga via Gcc
few other languages had similar abilities (Ada, Java (via annotations), ...) Yair > > > > -- Forwarded message -- > From: Miika > To: "gcc@gcc.gnu.org" > Cc: > Bcc: > Date: Fri, 03 Jun 2022 16:34:48 + > Subject: [RFC] Support for nonzero

Re: [RFC] Support for nonzero attribute

2022-06-03 Thread Jakub Jelinek via Gcc
On Fri, Jun 03, 2022 at 04:34:48PM +, Miika via Gcc wrote: > Hello, > > I would like to add support for new attribute: nonzero. > Nonzero attribute works the same way as nonnull but instead of checking for > NULL, it checks for integer or enum with value 0. NULL/nullptr is very special pointe

[RFC] Support for nonzero attribute

2022-06-03 Thread Miika via Gcc
Hello, I would like to add support for new attribute: nonzero. Nonzero attribute works the same way as nonnull but instead of checking for NULL, it checks for integer or enum with value 0. Nonzero attribute would issue warnings with new compiler flag -Wnonzero and -Wnonzero-compare. Nonzero coul