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 <jakub@redhat.com>
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.