[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

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

[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

[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.

[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

[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

[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-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