aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2020-05-19 07:58:33 +0200
committerRichard Biener <rguenther@suse.de>2020-05-20 09:39:49 +0200
commit4a88caf21a0a85129f6c985ca13ba3eb54ff5366 (patch)
treec76fd0b16bd0bf84e405c298ce7617b1e357d8d6 /gcc/c
parentdfa4fcdba374ed44d4aa1a22b2738f3f5c5b37af (diff)
downloadgcc-4a88caf21a0a85129f6c985ca13ba3eb54ff5366.zip
gcc-4a88caf21a0a85129f6c985ca13ba3eb54ff5366.tar.gz
gcc-4a88caf21a0a85129f6c985ca13ba3eb54ff5366.tar.bz2
c/95141 - fix bogus integer overflow warning
This fixes an integer overflow warning that ultimatively happens because of TREE_OVERFLOW propagating through transforms and the existing guard against this, 375 if (TREE_OVERFLOW_P (ret) 376 && !TREE_OVERFLOW_P (op0) 377 && !TREE_OVERFLOW_P (op1)) 378 overflow_warning (EXPR_LOC_OR_LOC (expr, input_location, being insufficient. Rather than trying to use sth like walk_tree to exhaustively walk operands (with the possibility of introducing quadraticness when folding larger expressions recursively) the following amends the above with an ad-hoc test for a binary op0 with a possibly constant op1. 2020-05-30 Richard Biener <rguenther@suse.de> PR c/95141 gcc/c * c-fold.c (c_fully_fold_internal): Enhance guard on overflow_warning. gcc/testsuite * gcc.dg/pr95141.c: New testcase.
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/c-fold.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.c
index 63becfe..bd21d24 100644
--- a/gcc/c/c-fold.c
+++ b/gcc/c/c-fold.c
@@ -374,6 +374,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
ret = fold (expr);
if (TREE_OVERFLOW_P (ret)
&& !TREE_OVERFLOW_P (op0)
+ && !(BINARY_CLASS_P (op0) && TREE_OVERFLOW_P (TREE_OPERAND (op0, 1)))
&& !TREE_OVERFLOW_P (op1))
overflow_warning (EXPR_LOC_OR_LOC (expr, input_location), ret, expr);
if (code == LSHIFT_EXPR