aboutsummaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2011-04-11 15:47:30 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2011-04-11 15:47:30 +0000
commite6313a7840a9266bb5777cd29b86885b63b3b24f (patch)
treec2b6fa4bc2cb17fae072b77ff6076eb93e0676c1 /gcc/stor-layout.c
parente69d7376989727cf50f2b674227b3e60725bb9af (diff)
downloadgcc-e6313a7840a9266bb5777cd29b86885b63b3b24f.zip
gcc-e6313a7840a9266bb5777cd29b86885b63b3b24f.tar.gz
gcc-e6313a7840a9266bb5777cd29b86885b63b3b24f.tar.bz2
stor-layout.c (layout_type): Compute all array index size operations in the original type.
2011-04-11 Richard Guenther <rguenther@suse.de> * stor-layout.c (layout_type): Compute all array index size operations in the original type. (initialize_sizetypes): Add comment. (set_sizetype): Do not set TREE_TYPE of a TREE_VEC. c-family/ * c-common.c (complete_array_type): Build a range type of proper type. From-SVN: r172261
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index a225dbf..ea0d44d 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -1996,15 +1996,16 @@ layout_type (tree type)
if (integer_zerop (element_size))
length = size_zero_node;
- /* The initial subtraction should happen in the original type so
+ /* The computation should happen in the original type so
that (possible) negative values are handled appropriately. */
else
length
- = size_binop (PLUS_EXPR, size_one_node,
- fold_convert (sizetype,
- fold_build2 (MINUS_EXPR,
- TREE_TYPE (lb),
- ub, lb)));
+ = fold_convert (sizetype,
+ fold_build2 (PLUS_EXPR, TREE_TYPE (lb),
+ build_int_cst (TREE_TYPE (lb), 1),
+ fold_build2 (MINUS_EXPR,
+ TREE_TYPE (lb),
+ ub, lb)));
TYPE_SIZE (type) = size_binop (MULT_EXPR, element_size,
fold_convert (bitsizetype,
@@ -2249,7 +2250,8 @@ initialize_sizetypes (void)
TYPE_SIZE_UNIT (t) = build_int_cst (t, GET_MODE_SIZE (SImode));
TYPE_PRECISION (t) = precision;
- set_min_and_max_values_for_integral_type (t, precision, true);
+ set_min_and_max_values_for_integral_type (t, precision,
+ /*is_unsigned=*/true);
sizetype = t;
bitsizetype = build_distinct_type_copy (t);
@@ -2284,7 +2286,6 @@ set_sizetype (tree type)
/* We want to use sizetype's cache, as we will be replacing that type. */
TYPE_CACHED_VALUES (t) = TYPE_CACHED_VALUES (sizetype);
TYPE_CACHED_VALUES_P (t) = TYPE_CACHED_VALUES_P (sizetype);
- TREE_TYPE (TYPE_CACHED_VALUES (t)) = type;
TYPE_UID (t) = TYPE_UID (sizetype);
TYPE_IS_SIZETYPE (t) = 1;