]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
stor-layout.c (layout_type): Do upper - lower in the native type, so as to properly...
authorRichard Henderson <rth@cygnus.com>
Wed, 11 Feb 1998 00:38:24 +0000 (16:38 -0800)
committerJeff Law <law@gcc.gnu.org>
Wed, 11 Feb 1998 00:38:24 +0000 (17:38 -0700)
        * stor-layout.c (layout_type): Do upper - lower in the native type,
        so as to properly handle negative indices.

From-SVN: r17844

gcc/ChangeLog
gcc/stor-layout.c

index 1ada1fb3014e34ea28121dd5bee01f5990113208..1f8d2de1d254c91f8b10469ac3cf18de88e94311 100644 (file)
@@ -1,3 +1,8 @@
+Wed Feb 11 01:39:47 1998  Richard Henderson  <rth@cygnus.com>
+
+       * stor-layout.c (layout_type): Do upper - lower in the native type,
+       so as to properly handle negative indices.
+
 Tue Feb 10 00:26:25 1998  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
        * rs6000.c (setup_incoming_varargs): Always set rs6000_sysv_varargs_p.
index 2ccf45ee1f4cf21a12804b000f39a2369f96fba3..1ef998bfa8354561c79885e31d1ad99e3257bbb4 100644 (file)
@@ -777,8 +777,11 @@ layout_type (type)
                                         lb, 0))
              ub = TREE_OPERAND (ub, 0);
 
+           /* The initial subtraction should happen in the original type so
+              that (possible) negative values are handled appropriately.  */
            length = size_binop (PLUS_EXPR, size_one_node,
-                                size_binop (MINUS_EXPR, ub, lb));
+                                fold (build (MINUS_EXPR, TREE_TYPE (lb),
+                                             ub, lb)));
 
            /* If neither bound is a constant and sizetype is signed, make
               sure the size is never negative.  We should really do this