This is a first step towards deprecating -Wstrict_overflow. The warning
is rooted in several places throughout the code, fold-const.cc functions
being one of them (via fold_overload_warn()).
These helpers are used in other files as well so the approach taken is to
gradually remove it from fold-const.cc while fixing the existing callers
along the way.
gcc/c-family/ChangeLog:
* c-warn.cc (warn_logical_operator): Removed strict_overflow_p
variable.
gcc/ChangeLog:
* fold-const.cc (make_range_step): Likewise.
(make_range): Likewise.
(fold_range_test): Likewise.
* fold-const.h (make_range): Likewise.
(make_range_step): Likewise.
* tree-ssa-reassoc.cc (init_range_entry): Likewise.
---
gcc/c-family/c-warn.cc | 5 ++---
gcc/fold-const.cc | 28 ++++++----------------------
gcc/fold-const.h | 4 ++--
gcc/tree-ssa-reassoc.cc | 3 +--
4 files changed, 11 insertions(+), 29 deletions(-)
diff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc
index 6de072582df..e956fae51ca 100644
--- a/gcc/c-family/c-warn.cc
+++ b/gcc/c-family/c-warn.cc
@@ -189,7 +189,6 @@ warn_logical_operator (location_t location, enum tree_code
code, tree type,
int or_op = (code == TRUTH_ORIF_EXPR || code == TRUTH_OR_EXPR);
int in0_p, in1_p, in_p;
tree low0, low1, low, high0, high1, high, lhs, rhs, tem;
- bool strict_overflow_p = false;
if (!warn_logical_op)
return;
@@ -264,7 +263,7 @@ warn_logical_operator (location_t location, enum tree_code
code, tree type,
portable code. */
op_left = unshare_expr (op_left);
walk_tree_without_duplicates (&op_left, unwrap_c_maybe_const, NULL);
- lhs = make_range (op_left, &in0_p, &low0, &high0, &strict_overflow_p);
+ lhs = make_range (op_left, &in0_p, &low0, &high0);
if (!lhs)
return;
@@ -279,7 +278,7 @@ warn_logical_operator (location_t location, enum tree_code
code, tree type,
op_right = unshare_expr (op_right);
walk_tree_without_duplicates (&op_right, unwrap_c_maybe_const, NULL);
- rhs = make_range (op_right, &in1_p, &low1, &high1, &strict_overflow_p);
+ rhs = make_range (op_right, &in1_p, &low1, &high1);
if (!rhs)
return;
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 47cd0053d31..1ea65d0ae15 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -5235,8 +5235,7 @@ range_binop (enum tree_code code, tree type, tree arg0,
int upper0_p,
tree
make_range_step (location_t loc, enum tree_code code, tree arg0, tree arg1,
- tree exp_type, tree *p_low, tree *p_high, int *p_in_p,
- bool *strict_overflow_p)
+ tree exp_type, tree *p_low, tree *p_high, int *p_in_p)
{
tree arg0_type = TREE_TYPE (arg0);
tree n_low, n_high, low = *p_low, high = *p_high;
@@ -5371,9 +5370,6 @@ make_range_step (location_t loc, enum tree_code code,
tree arg0, tree arg1,
|| (n_high != 0 && TREE_OVERFLOW (n_high)))
return NULL_TREE;
- if (TYPE_OVERFLOW_UNDEFINED (arg0_type))
- *strict_overflow_p = true;
-
normalize:
/* Check for an unsigned range which has wrapped around the maximum
value thus making n_high < n_low, and normalize it. */
@@ -5525,14 +5521,10 @@ make_range_step (location_t loc, enum tree_code code,
tree arg0, tree arg1,
variables denoted by PIN_P, PLOW, and PHIGH. Return the expression
actually being tested. *PLOW and *PHIGH will be made of the same
type as the returned expression. If EXP is not a comparison, we
- will most likely not be returning a useful value and range. Set
- *STRICT_OVERFLOW_P to true if the return value is only valid
- because signed overflow is undefined; otherwise, do not change
- *STRICT_OVERFLOW_P. */
+ will most likely not be returning a useful value and range. */
tree
-make_range (tree exp, int *pin_p, tree *plow, tree *phigh,
- bool *strict_overflow_p)
+make_range (tree exp, int *pin_p, tree *plow, tree *phigh)
{
enum tree_code code;
tree arg0, arg1 = NULL_TREE;
@@ -5570,7 +5562,7 @@ make_range (tree exp, int *pin_p, tree *plow, tree *phigh,
break;
nexp = make_range_step (loc, code, arg0, arg1, exp_type, &low,
- &high, &in_p, strict_overflow_p);
+ &high, &in_p);
if (nexp == NULL_TREE)
break;
exp = nexp;
@@ -6267,15 +6259,12 @@ fold_range_test (location_t loc, enum tree_code code,
tree type,
|| code == TRUTH_OR_EXPR);
int in0_p, in1_p, in_p;
tree low0, low1, low, high0, high1, high;
- bool strict_overflow_p = false;
tree tem, lhs, rhs;
- const char * const warnmsg = G_("assuming signed overflow does not occur "
- "when simplifying range test");
if (!INTEGRAL_TYPE_P (type))
return 0;
- lhs = make_range (op0, &in0_p, &low0, &high0, &strict_overflow_p);
+ lhs = make_range (op0, &in0_p, &low0, &high0);
/* If op0 is known true or false and this is a short-circuiting
operation we must not merge with op1 since that makes side-effects
unconditional. So special-case this. */
@@ -6283,7 +6272,7 @@ fold_range_test (location_t loc, enum tree_code code,
tree type,
&& ((code == TRUTH_ORIF_EXPR && in0_p)
|| (code == TRUTH_ANDIF_EXPR && !in0_p)))
return op0;
- rhs = make_range (op1, &in1_p, &low1, &high1, &strict_overflow_p);
+ rhs = make_range (op1, &in1_p, &low1, &high1);
/* If this is an OR operation, invert both sides; we will invert
again at the end. */
@@ -6302,8 +6291,6 @@ fold_range_test (location_t loc, enum tree_code code,
tree type,
: rhs != 0 ? rhs : integer_zero_node,
in_p, low, high))) != 0)
{
- if (strict_overflow_p)
- fold_overflow_warning (warnmsg, WARN_STRICT_OVERFLOW_COMPARISON);
return or_op ? invert_truthvalue_loc (loc, tem) : tem;
}
@@ -6340,9 +6327,6 @@ fold_range_test (location_t loc, enum tree_code code,
tree type,
or_op ? ! in1_p : in1_p,
low1, high1)) != 0)
{
- if (strict_overflow_p)
- fold_overflow_warning (warnmsg,
- WARN_STRICT_OVERFLOW_COMPARISON);
return build2_loc (loc, code == TRUTH_ANDIF_EXPR
? TRUTH_AND_EXPR : TRUTH_OR_EXPR,
type, lhs, rhs);
diff --git a/gcc/fold-const.h b/gcc/fold-const.h
index 37303147773..49d481398a7 100644
--- a/gcc/fold-const.h
+++ b/gcc/fold-const.h
@@ -213,9 +213,9 @@ extern bool tree_expr_maybe_signaling_nan_p (const_tree);
extern bool tree_expr_nan_p (const_tree);
extern bool tree_expr_maybe_nan_p (const_tree);
extern bool tree_expr_maybe_real_minus_zero_p (const_tree);
-extern tree make_range (tree, int *, tree *, tree *, bool *);
+extern tree make_range (tree, int *, tree *, tree *);
extern tree make_range_step (location_t, enum tree_code, tree, tree, tree,
- tree *, tree *, int *, bool *);
+ tree *, tree *, int *);
extern tree range_check_type (tree);
extern tree build_range_check (location_t, tree, tree, int, tree, tree);
extern bool merge_ranges (int *, tree *, tree *, int, tree, tree, int,
diff --git a/gcc/tree-ssa-reassoc.cc b/gcc/tree-ssa-reassoc.cc
index d2d2e084aa6..c0f6744dcfd 100644
--- a/gcc/tree-ssa-reassoc.cc
+++ b/gcc/tree-ssa-reassoc.cc
@@ -2659,8 +2659,7 @@ init_range_entry (struct range_entry *r, tree exp, gimple
*stmt)
return;
do_default:
nexp = make_range_step (loc, code, arg0, arg1, exp_type,
- &low, &high, &in_p,
- &strict_overflow_p);
+ &low, &high, &in_p);
if (nexp != NULL_TREE)
{
exp = nexp;
--
2.43.0