(output_constructor): Add support for non-zero lower array bound.
authorRichard Kenner <kenner@gcc.gnu.org>
Wed, 20 Oct 1993 21:58:21 +0000 (17:58 -0400)
committerRichard Kenner <kenner@gcc.gnu.org>
Wed, 20 Oct 1993 21:58:21 +0000 (17:58 -0400)
From-SVN: r5836

gcc/varasm.c

index 902646979fd18b6bc7cd6fcf297b0acb4c1140bd..497d3a55a5f4a73f32c37455aa2d1ee3dd82c4a8 100644 (file)
@@ -3401,6 +3401,7 @@ output_constructor (exp, size)
      int size;
 {
   register tree link, field = 0;
+  HOST_WIDE_INT min_index = 0;
   /* Number of bytes output or skipped so far.
      In other words, current position within the constructor.  */
   int total_bytes = 0;
@@ -3414,6 +3415,10 @@ output_constructor (exp, size)
   if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE)
     field = TYPE_FIELDS (TREE_TYPE (exp));
 
+  if (TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE)
+    min_index
+      = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (exp))));
+
   /* As LINK goes through the elements of the constant,
      FIELD goes through the structure fields, if the constant is a structure.
      if the constant is a union, then we override this,
@@ -3457,7 +3462,7 @@ output_constructor (exp, size)
          if (index != 0)
            bitpos = (TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (val)))
                      / BITS_PER_UNIT
-                     * TREE_INT_CST_LOW (index));
+                     * (TREE_INT_CST_LOW (index) - min_index));
 
          /* Output any buffered-up bit-fields preceding this element.  */
          if (byte_buffer_in_use)