This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Warn on always-false BIT_AND_EXPRs (PR 9944)


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]