aboutsummaryrefslogtreecommitdiff
path: root/gcc/expr.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2004-08-30 14:39:42 -0700
committerRichard Henderson <rth@gcc.gnu.org>2004-08-30 14:39:42 -0700
commitbc482be4939cf93e6ddb948a42c751824e0a2d3e (patch)
tree8fba8975eb49eb9a3a44b03ca04682c55bad8378 /gcc/expr.c
parent625be2863598fcaa489d1372ee825aff85ea7cec (diff)
downloadgcc-bc482be4939cf93e6ddb948a42c751824e0a2d3e.zip
gcc-bc482be4939cf93e6ddb948a42c751824e0a2d3e.tar.gz
gcc-bc482be4939cf93e6ddb948a42c751824e0a2d3e.tar.bz2
expr.c (array_ref_element_size): Force aligned_size back to sizetype.
* expr.c (array_ref_element_size): Force aligned_size back to sizetype. (component_ref_field_offset): Similarly for aligned_offset. * tree.c (recompute_tree_invarant_for_addr_expr): Mark raw low-bound, element-size, field-offset fields rather than computed values. From-SVN: r86803
Diffstat (limited to 'gcc/expr.c')
-rw-r--r--gcc/expr.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/gcc/expr.c b/gcc/expr.c
index d3c3e89..ca19b7a 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -5481,8 +5481,14 @@ array_ref_element_size (tree exp)
/* If a size was specified in the ARRAY_REF, it's the size measured
in alignment units of the element type. So multiply by that value. */
if (aligned_size)
- return size_binop (MULT_EXPR, aligned_size,
- size_int (TYPE_ALIGN (elmt_type) / BITS_PER_UNIT));
+ {
+ /* ??? tree_ssa_useless_type_conversion will eliminate casts to
+ sizetype from another type of the same width and signedness. */
+ if (TREE_TYPE (aligned_size) != sizetype)
+ aligned_size = fold_convert (sizetype, aligned_size);
+ return size_binop (MULT_EXPR, aligned_size,
+ size_int (TYPE_ALIGN (elmt_type) / BITS_PER_UNIT));
+ }
/* Otherwise, take the size from that of the element type. Substitute
any PLACEHOLDER_EXPR that we have. */
@@ -5541,8 +5547,14 @@ component_ref_field_offset (tree exp)
in units of DECL_OFFSET_ALIGN / BITS_PER_UNIT. So multiply by that
value. */
if (aligned_offset)
- return size_binop (MULT_EXPR, aligned_offset,
- size_int (DECL_OFFSET_ALIGN (field) / BITS_PER_UNIT));
+ {
+ /* ??? tree_ssa_useless_type_conversion will eliminate casts to
+ sizetype from another type of the same width and signedness. */
+ if (TREE_TYPE (aligned_offset) != sizetype)
+ aligned_offset = fold_convert (sizetype, aligned_offset);
+ return size_binop (MULT_EXPR, aligned_offset,
+ size_int (DECL_OFFSET_ALIGN (field) / BITS_PER_UNIT));
+ }
/* Otherwise, take the offset from that of the field. Substitute
any PLACEHOLDER_EXPR that we have. */