diff options
author | Jakub Jelinek <jakub@redhat.com> | 2008-08-29 20:59:13 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2008-08-29 20:59:13 +0200 |
commit | bf09f0e0e98713b4a76743a83dd47c82b34fa12a (patch) | |
tree | 60c9d72ca2cc8e6c55dbfe40008bdbd5f5759039 /gcc/fold-const.c | |
parent | 98c0cbd30a77148e1baa024678eeae6ff2a925c0 (diff) | |
download | gcc-bf09f0e0e98713b4a76743a83dd47c82b34fa12a.zip gcc-bf09f0e0e98713b4a76743a83dd47c82b34fa12a.tar.gz gcc-bf09f0e0e98713b4a76743a83dd47c82b34fa12a.tar.bz2 |
re PR middle-end/37261 (Spurious (?) "integer overflow in expression" warnings)
PR c/37261
* fold-const.c (fold_binary): In (X | C1) & C2 canonicalization
compute new & and | in type rather than TREE_TYPE (arg0).
* gcc.dg/pr37261.c: New test.
From-SVN: r139784
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index af16433..01936bd 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -10737,14 +10737,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) && TREE_CODE (arg1) == INTEGER_CST && TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST) { - tree tmp1 = fold_convert (TREE_TYPE (arg0), arg1); - tree tmp2 = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg0), - TREE_OPERAND (arg0, 0), tmp1); - tree tmp3 = fold_build2 (BIT_AND_EXPR, TREE_TYPE (arg0), - TREE_OPERAND (arg0, 1), tmp1); + tree tmp1 = fold_convert (type, arg1); + tree tmp2 = fold_convert (type, TREE_OPERAND (arg0, 0)); + tree tmp3 = fold_convert (type, TREE_OPERAND (arg0, 1)); + tmp2 = fold_build2 (BIT_AND_EXPR, type, tmp2, tmp1); + tmp3 = fold_build2 (BIT_AND_EXPR, type, tmp3, tmp1); return fold_convert (type, - fold_build2 (BIT_IOR_EXPR, TREE_TYPE (arg0), - tmp2, tmp3)); + fold_build2 (BIT_IOR_EXPR, type, tmp2, tmp3)); } /* (X | Y) & Y is (X, Y). */ |