Re: [C/C++ PATCH] Further -Wlogical-not-parentheses improvement (PR c/65120)

2015-03-09 Thread Joseph Myers
On Mon, 9 Mar 2015, Jakub Jelinek wrote:

> Hi!
> 
> As mentioned by richi, !x == 0 is actually equivalent to !(x == 0)
> and x != 0 and !x != 0 is equivalent to !(x != 0) and x == 0, so this
> patch adjusts the warning not to warn in that case, as adding parens
> doesn't change anything.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> 2015-03-09  Jakub Jelinek  
> 
>   PR c/65120
>   * c-common.c (warn_logical_not_parentheses): Don't warn for
>   !x == 0 or !x != 0.
> 
>   * c-typeck.c (parser_build_binary_op): Check for tcc_comparison
>   before preparing arguments to warn_logical_not_parentheses.

The C front-end changes are OK.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [C/C++ PATCH] Further -Wlogical-not-parentheses improvement (PR c/65120)

2015-03-09 Thread Jeff Law

On 03/09/15 15:26, Jakub Jelinek wrote:

Hi!

As mentioned by richi, !x == 0 is actually equivalent to !(x == 0)
and x != 0 and !x != 0 is equivalent to !(x != 0) and x == 0, so this
patch adjusts the warning not to warn in that case, as adding parens
doesn't change anything.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2015-03-09  Jakub Jelinek  

PR c/65120
* c-common.c (warn_logical_not_parentheses): Don't warn for
!x == 0 or !x != 0.

* c-typeck.c (parser_build_binary_op): Check for tcc_comparison
before preparing arguments to warn_logical_not_parentheses.

* parser.c (cp_parser_binary_expression): Check for tcc_comparison
before preparing arguments to warn_logical_not_parentheses.
Use maybe_constant_value on rhs.

* c-c++-common/pr49706.c (fn2): Don't expect warning if enumerator
on rhs is 0.
(fn4): New test.
* c-c++-common/pr65120.c: New test.

C++ and testsuite bits are fine too.
jeff