On Fri, Feb 20, 2015 at 01:03:26AM +0100, Jakub Jelinek wrote:
> Hi!
> 
> As reported, !!x == y is quite common in the Linux kernel
> and unlike the !x == y case it usually doesn't mean mistyped
> !(x == y) or x != y.  clang++ apparently doesn't warn about that
> either, and it doesn't warn even about the case where ! is applied
> to a bool.

Note that first version of -Wlogical-not-parentheses didn't warn
when LHS had a boolean type, this has been changed later on.  I have
no strong preference either way.

> As the argument is already folded, it isn't easy to determine
> those cases always, but I hope the following is sufficient until we switch
> to late folding.
 
Yes, this means that we warn for

  return !(a != 0) == b;

but not for

  return !(a == 0) == b;

I think we can live with that for now.

> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> 2015-02-19  Jakub Jelinek  <ja...@redhat.com>
> 
>       PR c/65120
>       * c-typeck.c (parser_build_binary_op): Don't warn for
>       !!x == y or !b == y where b is _Bool.
> 
>       * parser.c (cp_parser_binary_expression): Don't warn for
>       !!x == y or !b == y where b is bool.
> 
>       * c-c++-common/pr49706.c: Adjust tests for not warning
>       about !!x == y or !b == y where b is boolean, and add
>       some further tests.
>       * c-c++-common/pr62199-2.c: Likewise.

The C part is ok.  Maybe we should also update the docs to reflect that
-Wlogical-not-parentheses does not warn if the RHS *or LHS* operand is of
a boolean type.  Thanks,

        Marek

Reply via email to