diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-02-26 13:09:58 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-02-26 13:09:58 +0000 |
commit | b8053af55de78a3f080783e5113fd6452e5a43c5 (patch) | |
tree | a5906142e844e296abb7382e34657faf4e58f74f /gcc/tree-vrp.c | |
parent | 4896274c9597b09d4c61bdd2efb3201a72634b3c (diff) | |
download | gcc-b8053af55de78a3f080783e5113fd6452e5a43c5.tar.gz |
2008-02-26 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk r132671
Merged revisions 132452-132671 via svnmerge from
svn+ssh://bstarynk@gcc.gnu.org/svn/gcc/trunk
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@132672 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index f9615d1f815..eaeaea08902 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -5077,6 +5077,48 @@ vrp_evaluate_conditional (tree cond, tree stmt) } } + if (warn_type_limits + && ret + && TREE_CODE_CLASS (TREE_CODE (cond)) == tcc_comparison) + { + /* If the comparison is being folded and the operand on the LHS + is being compared against a constant value that is outside of + the natural range of OP0's type, then the predicate will + always fold regardless of the value of OP0. If -Wtype-limits + was specified, emit a warning. */ + const char *warnmsg = NULL; + 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)) + { + 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"); + } + + if (warnmsg) + { + location_t locus; + + if (!EXPR_HAS_LOCATION (stmt)) + locus = input_location; + else + locus = EXPR_LOCATION (stmt); + + warning (OPT_Wtype_limits, "%H%s", &locus, warnmsg); + } + } + return ret; } |