On 04/28/2015 04:49 AM, Marek Polacek wrote:
This improves -Wbool-compare a bit: boolean >= 0 is always true, on the other
hand boolean < 0 is always false, and similar.

One feature/bug is that in C++ we don't warn for e.g. bool >= false, since the
warning cares about <bool> CMP <non-bool> or <non-bool> CMP <bool>.  I can fix
that in a follow-up if anyone wants me to.

Bootstrapped (-> GCC itself is clean)/regtested on x86_64-linux, ok for trunk?

2015-04-28  Marek Polacek  <pola...@redhat.com>

        PR c/64610
        * c-common.c (maybe_warn_bool_compare): Warn when comparing a boolean
        with 0/1.

        * c-c++-common/Wbool-compare-1.c (fn1): Remove a few lines.
        * c-c++-common/Wbool-compare-2.c: New test.
OK.
jeff

Reply via email to