diff options
author | Jakub Jelinek <jakub@redhat.com> | 2009-05-20 23:09:11 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2009-05-20 23:09:11 +0200 |
commit | 776248b87e53e18386405561ca260c665ca6bdb7 (patch) | |
tree | befe401eb3201bc82589618ec4f366a7daa6ced7 /gcc/fold-const.c | |
parent | 6dea8e99a9430efa08176dfa5beb94fa9996480b (diff) | |
download | gcc-776248b87e53e18386405561ca260c665ca6bdb7.zip gcc-776248b87e53e18386405561ca260c665ca6bdb7.tar.gz gcc-776248b87e53e18386405561ca260c665ca6bdb7.tar.bz2 |
re PR middle-end/40204 (segfault with bitfields in structs)
PR middle-end/40204
* fold-const.c (fold_binary) <case BIT_AND_EXPR>: Avoid infinite
recursion if build_int_cst_type returns the same INTEGER_CST as
arg1.
* gcc.c-torture/compile/pr40204.c: New test.
From-SVN: r147749
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 0ac9e29..e322ecb 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -11382,6 +11382,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) if (prec < HOST_BITS_PER_WIDE_INT || newmask == ~(unsigned HOST_WIDE_INT) 0) { + tree newmaskt; + if (shift_type != TREE_TYPE (arg0)) { tem = fold_build2 (TREE_CODE (arg0), shift_type, @@ -11392,9 +11394,9 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) } else tem = op0; - return fold_build2 (BIT_AND_EXPR, type, tem, - build_int_cst_type (TREE_TYPE (op1), - newmask)); + newmaskt = build_int_cst_type (TREE_TYPE (op1), newmask); + if (!tree_int_cst_equal (newmaskt, arg1)) + return fold_build2 (BIT_AND_EXPR, type, tem, newmaskt); } } } |