summaryrefslogtreecommitdiffstats
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2007-07-12 10:27:51 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2007-07-12 10:27:51 +0000
commit299888457f91c854ff9ce63d1cd004d7d7df1bc1 (patch)
treeb01916e56bf1aadf986d4b4a11b1a17c5a1f24f0 /gcc/gimplify.c
parent235835a0f3a5216518cc45e50836b3a268f06238 (diff)
downloadppe42-gcc-299888457f91c854ff9ce63d1cd004d7d7df1bc1.tar.gz
ppe42-gcc-299888457f91c854ff9ce63d1cd004d7d7df1bc1.zip
2007-07-12 Richard Guenther <rguenther@suse.de>
* gimplify.c (gimplify_conversion): Make sure that the result from maybe_fold_offset_to_reference is trivially convertible to the desired type before doing the simplification. (gimplify_expr): Likewise. * fold-const.c (fold_binary): Use the correct types for building the simplified expression. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126577 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 3b5fa895238..12ed309538b 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1648,7 +1648,11 @@ gimplify_conversion (tree *expr_p)
&& (tem = maybe_fold_offset_to_reference
(TREE_OPERAND (*expr_p, 0),
integer_zero_node, TREE_TYPE (TREE_TYPE (*expr_p)))))
- *expr_p = build_fold_addr_expr_with_type (tem, TREE_TYPE (*expr_p));
+ {
+ tree ptr_type = build_pointer_type (TREE_TYPE (tem));
+ if (useless_type_conversion_p (TREE_TYPE (*expr_p), ptr_type))
+ *expr_p = build_fold_addr_expr_with_type (tem, ptr_type);
+ }
/* If we still have a conversion at the toplevel,
then canonicalize some constructs. */
@@ -5987,9 +5991,12 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p,
(TREE_OPERAND (*expr_p, 0), TREE_OPERAND (*expr_p, 1),
TREE_TYPE (TREE_TYPE (*expr_p)))))
{
- *expr_p = build_fold_addr_expr_with_type (tmp,
- TREE_TYPE (*expr_p));
- break;
+ tree ptr_type = build_pointer_type (TREE_TYPE (tmp));
+ if (useless_type_conversion_p (TREE_TYPE (*expr_p), ptr_type))
+ {
+ *expr_p = build_fold_addr_expr_with_type (tmp, ptr_type);
+ break;
+ }
}
/* Convert (void *)&a + 4 into (void *)&a[1]. */
if (TREE_CODE (TREE_OPERAND (*expr_p, 0)) == NOP_EXPR
OpenPOWER on IntegriCloud