This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Warn on always-false BIT_AND_EXPRs (PR 9944)
- From: Neil Booth <neil at daikokuya dot co dot uk>
- To: John Levon <levon at movementarian dot org>
- Cc: gcc-patches at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Date: Wed, 5 Mar 2003 07:07:36 +0000
- Subject: Re: [PATCH] Warn on always-false BIT_AND_EXPRs (PR 9944)
- References: <20030305005440.GA49566@compsoc.man.ac.uk>
John Levon wrote:-
> case BIT_AND_EXPR:
> + /* give a warning for (!ua & 0x4) and similar cases */
> + if (warn_boolean_bitwise_and)
> + {
> + int op0not1 = TREE_CODE (op0) == INTEGER_CST && !integer_onep (op0);
> + int op1not1 = TREE_CODE (op1) == INTEGER_CST && !integer_onep (op1);
> + if ((op0not1 && boolean_value_p (op1)) || (op1not1 && boolean_value_p (op0)))
> + warning ("bitwise and expression is always false");
> + }
> +
> + /* fallthrough */
> +
Don't forget coding style: long line should be broken before the ||,
and comments are full sentences, beginning with capital letter, and
ending in ". "
Neil.