diff options
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 16dfd3b..01ce961 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -13485,9 +13485,14 @@ tree_expr_nonnegative_warnv_p (tree t, bool *strict_overflow_p) /* ... fall through ... */ default: - if (truth_value_p (TREE_CODE (t))) - /* Truth values evaluate to 0 or 1, which is nonnegative. */ - return true; + { + tree type = TREE_TYPE (t); + if ((TYPE_PRECISION (type) != 1 || TYPE_UNSIGNED (type)) + && truth_value_p (TREE_CODE (t))) + /* Truth values evaluate to 0 or 1, which is nonnegative unless we + have a signed:1 type (where the value is -1 and 0). */ + return true; + } } /* We don't know sign of `t', so be conservative and return false. */ |