This reverts parts of

2011-04-11  Richard Guenther  <rguent...@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.

and retains the use of size_binop in layout_type while still preserving
signedness.  We then just need to make sure to always use a
sizetype for domain types, the only case where we don't being
in complete_array_type for a[].

Bootstrapped and tested on x86_64-unknown-linux-gnu, committed
(c-common.c piece as obvious).

Richard.

2011-09-05  Richard Guenther  <rguent...@suse.de>

        * stor-layout.c (layout_type): Use size_binop for array size
        calculations.

        c-family/
        * c-common.c (complete_array_type): Use ssize_int (-1) instead
        of integer_minus_one_node for empty array upper bounds.

Index: gcc/stor-layout.c
===================================================================
--- gcc/stor-layout.c   (revision 178523)
+++ gcc/stor-layout.c   (working copy)
@@ -1959,16 +1959,15 @@ layout_type (tree type)
            if (integer_zerop (element_size))
              length = size_zero_node;
 
-           /* The computation should happen in the original type so
-              that (possible) negative values are handled appropriately.  */
+           /* The computation should happen in the original signedness so
+              that (possible) negative values are handled appropriately
+              when determining overflow.  */
            else
              length
                = 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)));
+                               size_binop (PLUS_EXPR,
+                                           build_int_cst (TREE_TYPE (lb), 1),
+                                           size_binop (MINUS_EXPR, ub, lb)));
 
            TYPE_SIZE (type) = size_binop (MULT_EXPR, element_size,
                                           fold_convert (bitsizetype,
Index: gcc/c-family/c-common.c
===================================================================
--- gcc/c-family/c-common.c     (revision 178523)
+++ gcc/c-family/c-common.c     (working copy)
@@ -8844,7 +8844,7 @@ complete_array_type (tree *ptype, tree i
            {
              if (pedantic)
                failure = 3;
-             maxindex = integer_minus_one_node;
+             maxindex = ssize_int (-1);
            }
          else
            {

Reply via email to