diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-08-21 09:18:15 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-08-21 09:18:15 +0000 |
commit | 69f111d5078d349329ae81f85ab13b792049c21c (patch) | |
tree | da8009658e74e845d6bc8c65006d9ea505a606a8 /gcc/fold-const.c | |
parent | 15796f6161bb65cfc2dbe4f21abbf14161fda407 (diff) | |
download | gcc-69f111d5078d349329ae81f85ab13b792049c21c.tar.gz |
2007-08-21 Richard Guenther <rguenther@suse.de>
* fold-const.c (fold_binary): Revert removing of index +p PTR
* folding.
* gcc.dg/pointer-arith-10.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@127660 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 8faf77d8751..33467eb88f2 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9528,6 +9528,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) fold_convert (sizetype, arg1), fold_convert (sizetype, arg0))); + /* index +p PTR -> PTR +p index */ + if (POINTER_TYPE_P (TREE_TYPE (arg1)) + && INTEGRAL_TYPE_P (TREE_TYPE (arg0))) + return fold_build2 (POINTER_PLUS_EXPR, type, + fold_convert (type, arg1), + fold_convert (sizetype, arg0)); + /* (PTR +p B) +p A -> PTR +p (B + A) */ if (TREE_CODE (arg0) == POINTER_PLUS_EXPR) { |