------- Comment #5 from manu at gcc dot gnu dot org 2008-02-05 11:21 ------- You should use OPT_Wtype_limits instead of OPT_Wextra.
Also, the code could simply do: + tree op0 = TREE_OPERAND (cond, 0); + tree op1 = TREE_OPERAND (cond, 1); + tree type = TREE_TYPE (op0); + value_range_t *vr0 = get_value_range (op0); + + if (vr0->type != VR_VARYING + && INTEGRAL_TYPE_P (type) + && vrp_val_is_min (vr0->min) + && vrp_val_is_max (vr0->max) + && is_gimple_min_invariant (op1)) + { + location_t locus; + const char *warnmsg = NULL; + + if (!EXPR_HAS_LOCATION (stmt)) + locus = input_location; + else + locus = EXPR_LOCATION (stmt); + + if (integer_zerop (ret)) + warnmsg = G_("comparison always false due to limited range of " + "data type"); + else + warnmsg = G_("comparison always true due to limited range of " + "data type"); + + warning (OPT_Wextra, "%H%s", &locus, warnmsg); + } And BTW, what is G_ for? -- manu at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2007-11-13 04:55:56 |2008-02-05 11:21:26 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33738