aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2007-08-21 08:23:50 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2007-08-21 08:23:50 +0000
commit8015455a87e3e516d3238fb3231ab50214234289 (patch)
treea051cfbef7bee98d995fa7021f0aa586f2b4e177 /gcc/fold-const.c
parent66644666a511e85b232e586e27262ab0c90fc434 (diff)
downloadgcc-8015455a87e3e516d3238fb3231ab50214234289.zip
gcc-8015455a87e3e516d3238fb3231ab50214234289.tar.gz
gcc-8015455a87e3e516d3238fb3231ab50214234289.tar.bz2
re PR middle-end/33122 (Mistaken type mismatch error prevents bootstrap)
2007-08-21 Richard Guenther <rguenther@suse.de> PR middle-end/33122 * fold-const.c (fold_binary): Remove index +p PTR folding. Fix types of POINTER_PLUS_EXPR generated by folding of (PTR +p B) +p A. * gcc.c-torture/compile/pr33122.c: New testcase. From-SVN: r127659
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index d5d0f1e..8faf77d 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -9528,20 +9528,17 @@ 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)
{
tree inner;
tree arg01 = fold_convert (sizetype, TREE_OPERAND (arg0, 1));
tree arg00 = TREE_OPERAND (arg0, 0);
- inner = fold_build2 (PLUS_EXPR, sizetype, arg01, fold_convert (sizetype, arg1));
- return fold_build2 (POINTER_PLUS_EXPR, type, arg00, inner);
+ inner = fold_build2 (PLUS_EXPR, sizetype,
+ arg01, fold_convert (sizetype, arg1));
+ return fold_convert (type,
+ fold_build2 (POINTER_PLUS_EXPR,
+ TREE_TYPE (arg00), arg00, inner));
}
/* PTR_CST +p CST -> CST1 */
@@ -9559,6 +9556,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
}
return NULL_TREE;
+
case PLUS_EXPR:
/* PTR + INT -> (INT)(PTR p+ INT) */
if (POINTER_TYPE_P (TREE_TYPE (arg0))