Commit e6313a78 by Richard Guenther Committed by Richard Biener

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
parent e69d7376
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.
2011-04-11 Joseph Myers <joseph@codesourcery.com> 2011-04-11 Joseph Myers <joseph@codesourcery.com>
* common.opt (Tbss=, Tdata=, Ttext=): New options. * common.opt (Tbss=, Tdata=, Ttext=): New options.
......
2011-04-11 Richard Guenther <rguenther@suse.de>
* c-common.c (complete_array_type): Build a range type of
proper type.
2011-04-08 Nathan Froyd <froydnj@codesourcery.com> 2011-04-08 Nathan Froyd <froydnj@codesourcery.com>
* c-common.c (handle_sentinel_attribute): Don't use TYPE_ARG_TYPES. * c-common.c (handle_sentinel_attribute): Don't use TYPE_ARG_TYPES.
......
...@@ -8810,7 +8810,9 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default) ...@@ -8810,7 +8810,9 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default)
TYPE_LANG_FLAG_? bits that the front end may have set. */ TYPE_LANG_FLAG_? bits that the front end may have set. */
main_type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type)); main_type = build_distinct_type_copy (TYPE_MAIN_VARIANT (type));
TREE_TYPE (main_type) = unqual_elt; TREE_TYPE (main_type) = unqual_elt;
TYPE_DOMAIN (main_type) = build_index_type (maxindex); TYPE_DOMAIN (main_type)
= build_range_type (TREE_TYPE (maxindex),
build_int_cst (TREE_TYPE (maxindex), 0), maxindex);
layout_type (main_type); layout_type (main_type);
/* Make sure we have the canonical MAIN_TYPE. */ /* Make sure we have the canonical MAIN_TYPE. */
......
...@@ -1996,15 +1996,16 @@ layout_type (tree type) ...@@ -1996,15 +1996,16 @@ layout_type (tree type)
if (integer_zerop (element_size)) if (integer_zerop (element_size))
length = size_zero_node; 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. */ that (possible) negative values are handled appropriately. */
else else
length length
= size_binop (PLUS_EXPR, size_one_node, = fold_convert (sizetype,
fold_convert (sizetype, fold_build2 (PLUS_EXPR, TREE_TYPE (lb),
fold_build2 (MINUS_EXPR, build_int_cst (TREE_TYPE (lb), 1),
TREE_TYPE (lb), fold_build2 (MINUS_EXPR,
ub, lb))); TREE_TYPE (lb),
ub, lb)));
TYPE_SIZE (type) = size_binop (MULT_EXPR, element_size, TYPE_SIZE (type) = size_binop (MULT_EXPR, element_size,
fold_convert (bitsizetype, fold_convert (bitsizetype,
...@@ -2249,7 +2250,8 @@ initialize_sizetypes (void) ...@@ -2249,7 +2250,8 @@ initialize_sizetypes (void)
TYPE_SIZE_UNIT (t) = build_int_cst (t, GET_MODE_SIZE (SImode)); TYPE_SIZE_UNIT (t) = build_int_cst (t, GET_MODE_SIZE (SImode));
TYPE_PRECISION (t) = precision; 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; sizetype = t;
bitsizetype = build_distinct_type_copy (t); bitsizetype = build_distinct_type_copy (t);
...@@ -2284,7 +2286,6 @@ set_sizetype (tree type) ...@@ -2284,7 +2286,6 @@ set_sizetype (tree type)
/* We want to use sizetype's cache, as we will be replacing that 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 (t) = TYPE_CACHED_VALUES (sizetype);
TYPE_CACHED_VALUES_P (t) = TYPE_CACHED_VALUES_P (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_UID (t) = TYPE_UID (sizetype);
TYPE_IS_SIZETYPE (t) = 1; TYPE_IS_SIZETYPE (t) = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment