Re: C/C++ PATCH to implement -Wbool-operation (PR c/77490)

2016-10-01 Thread Marek Polacek
On Sat, Oct 01, 2016 at 01:46:02AM +0200, Jakub Jelinek wrote: > On Fri, Sep 23, 2016 at 12:44:22PM +0200, Marek Polacek wrote: > > 2016-09-23 Marek Polacek > > > > PR c/77490 > ... > > * c-c++-common/Wbool-operation-1.c: New test. > > I've noticed this test fails

Re: C/C++ PATCH to implement -Wbool-operation (PR c/77490)

2016-09-30 Thread Jakub Jelinek
On Fri, Sep 23, 2016 at 12:44:22PM +0200, Marek Polacek wrote: > 2016-09-23 Marek Polacek > > PR c/77490 ... > * c-c++-common/Wbool-operation-1.c: New test. I've noticed this test fails on i686-linux and likely also on powerpc-linux. Fixed thusly, committed to

Re: C/C++ PATCH to implement -Wbool-operation (PR c/77490)

2016-09-23 Thread Joseph Myers
On Fri, 23 Sep 2016, Marek Polacek wrote: > On Thu, Sep 22, 2016 at 05:24:31PM +, Joseph Myers wrote: > > On Wed, 21 Sep 2016, Marek Polacek wrote: > > > > > > > > And let's refer to "expression of type bool" rather than "boolean > > > > > > expression". > > > > > > > > > > Adjusted (and in

Re: C/C++ PATCH to implement -Wbool-operation (PR c/77490)

2016-09-23 Thread Marek Polacek
On Thu, Sep 22, 2016 at 05:24:31PM +, Joseph Myers wrote: > On Wed, 21 Sep 2016, Marek Polacek wrote: > > > > > > And let's refer to "expression of type bool" rather than "boolean > > > > > expression". > > > > > > > > Adjusted (and in the C FE too). > > > > > > Hmm, I'm not sure that

Re: C/C++ PATCH to implement -Wbool-operation (PR c/77490)

2016-09-22 Thread Joseph Myers
On Wed, 21 Sep 2016, Marek Polacek wrote: > > > > And let's refer to "expression of type bool" rather than "boolean > > > > expression". > > > > > > Adjusted (and in the C FE too). > > > > Hmm, I'm not sure that change is right for C. But the C++ hunk is OK. > > Thanks. Joseph, how about the

Re: C/C++ PATCH to implement -Wbool-operation (PR c/77490)

2016-09-21 Thread Jason Merrill
On 09/20/2016 01:13 PM, Marek Polacek wrote: On Mon, Sep 19, 2016 at 02:41:04PM -0400, Jason Merrill wrote: On 09/16/2016 05:01 AM, Marek Polacek wrote: @@ -5853,7 +5853,16 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,

Re: C/C++ PATCH to implement -Wbool-operation (PR c/77490)

2016-09-21 Thread Marek Polacek
On Wed, Sep 21, 2016 at 11:37:32AM -0400, Jason Merrill wrote: > On 09/20/2016 01:13 PM, Marek Polacek wrote: > > On Mon, Sep 19, 2016 at 02:41:04PM -0400, Jason Merrill wrote: > > > On 09/16/2016 05:01 AM, Marek Polacek wrote: > > > > @@ -5853,7 +5853,16 @@ cp_build_unary_op (enum tree_code code,

Re: C/C++ PATCH to implement -Wbool-operation (PR c/77490)

2016-09-20 Thread Marek Polacek
On Mon, Sep 19, 2016 at 02:41:04PM -0400, Jason Merrill wrote: > On 09/16/2016 05:01 AM, Marek Polacek wrote: > > @@ -5853,7 +5853,16 @@ cp_build_unary_op (enum tree_code code, tree xarg, > > bool noconvert, > >arg, true))) > > errstring =

Re: C/C++ PATCH to implement -Wbool-operation (PR c/77490)

2016-09-19 Thread Jason Merrill
On 09/16/2016 05:01 AM, Marek Polacek wrote: @@ -5853,7 +5853,16 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert, arg, true))) errstring = _("wrong type argument to bit-complement"); else if (!noconvert &&

Re: C/C++ PATCH to implement -Wbool-operation (PR c/77490)

2016-09-16 Thread Marek Polacek
On Thu, Sep 15, 2016 at 04:45:03PM -0400, Eric Gallager wrote: > > +@item -Wbool-operation > > +@opindex Wno-bool-operation > > +@opindex Wbool-operation > > +Warn about suspicious operations on expressions of a boolean type. For > > +instance, bitwise negation of a boolean is very likely a bug

Re: C/C++ PATCH to implement -Wbool-operation (PR c/77490)

2016-09-15 Thread Eric Gallager
Hi, I have some comments/questions in-line: On 9/15/16, Marek Polacek wrote: > Now that the C++ FE boolean in/decrement changes are in, I can move > forwards with this patch which implements a new warning named -Wbool-operation > (better names?) which warns about nonsensical

C/C++ PATCH to implement -Wbool-operation (PR c/77490)

2016-09-15 Thread Marek Polacek
Now that the C++ FE boolean in/decrement changes are in, I can move forwards with this patch which implements a new warning named -Wbool-operation (better names?) which warns about nonsensical code such as ~bool, ~(i == 10), or bool-- (in C). It could also warn for other operations such as * or /