On 12/02/07, Dirk Mueller <dmueller@suse.de> wrote:
> +
> + switch (code)
> + {
> + case TRUTH_ANDIF_EXPR:
> + case TRUTH_ORIF_EXPR:
> + case TRUTH_AND_EXPR:
> + case TRUTH_OR_EXPR:
> + if (INTEGRAL_TYPE_P (TREE_TYPE (arg1))
> + && !CONSTANT_CLASS_P (arg1)
> + && !expl_eq_arg1
> + && TREE_CODE (arg2) == INTEGER_CST
> + && !integer_zerop (arg2))
> + {
> + warning (OPT_Walways_true, "logical %<%s%> with non-zero constant "
> + "will always evaluate as true",
> + ((code == TRUTH_ANDIF_EXPR)
> + || (code == TRUTH_AND_EXPR)) ? "&&" : "||");
> + expl_eq_arg1 = expl_eq_arg2 = true;
> + }
Just a nitpick. This will print "&&" or "||" even if the code contains
"and" or "or". I think there is already a bug about this somewhere but
I am not sure whether it is a general defect in GCC or something that
must be fixed case by case.
Cheers,
Manuel.