]> 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:43:32 +0000 (16:43 -0800)
committerJeff Law <law@gcc.gnu.org>
Wed, 11 Feb 1998 00:43:32 +0000 (17:43 -0700)
        * stor-layout.c (layout_type): Do upper - lower in the native type,
        so as to properly handle negative indices.

From-SVN: r17846

gcc/ChangeLog
gcc/stor-layout.c

index ec4b15c8a8dd6f1ee34477743bf58c96256e0dcb..17e7c76022f5daece20da18f380498cba5ebc506 100644 (file)
@@ -1,3 +1,8 @@
+Wed Feb 11 01:44:13 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.
+
 Wed Feb 11 01:35:55 1998  Robert Lipe   <robertl@dgii.com>
 
        * except.c (start_dynamic_cleanup): Remove unused variable 'dhc'.
index 0e4e5087c21c3b7098286d34742ea2b86640691d..491af0ffcd19218d689c74861eb7aae2de0aa525 100644 (file)
@@ -786,8 +786,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