From 7f166b0a8e4cf02f0e297429471ab95078820a48 Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Tue, 28 Mar 2006 05:01:27 +0000 Subject: [PATCH] re PR middle-end/22524 (fold (or the front-ends) produces UNARY (BIT_NOT_EXPR) tree with mismatch types) PR middle-end/22524 * fold-const.c (fold_binary) : Call fold_convert to cast BIT_NOT_EXPR operand to the correct type. From-SVN: r112438 --- gcc/ChangeLog | 6 ++++++ gcc/fold-const.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b8a8a7d59fa..f57f710a61d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-03-27 Roger Sayle + + PR middle-end/22524 + * fold-const.c (fold_binary) : Call fold_convert to + cast BIT_NOT_EXPR operand to the correct type. + 2006-03-27 Sebastian Pop * tree-loop-linear.c: Don't include varray.h. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 9ea3232d4f7..1381184f115 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8186,7 +8186,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (INTEGRAL_TYPE_P (type) && TREE_CODE (arg0) == NEGATE_EXPR && integer_onep (arg1)) - return fold_build1 (BIT_NOT_EXPR, type, TREE_OPERAND (arg0, 0)); + return fold_build1 (BIT_NOT_EXPR, type, + fold_convert (type, TREE_OPERAND (arg0, 0))); /* Convert -1 - A to ~A. */ if (INTEGRAL_TYPE_P (type) -- 2.30.2