(store_constructor, ARRAY_TYPE): Use code for non-integer INDEX for non-integer ELTTY...
authorRichard Kenner <kenner@gcc.gnu.org>
Fri, 10 Feb 1995 22:37:38 +0000 (17:37 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Fri, 10 Feb 1995 22:37:38 +0000 (17:37 -0500)
(store_constructor, ARRAY_TYPE): Use code for non-integer INDEX for
non-integer ELTTYPE size.
Allow INDEX to be zero in code and divide size by BITS_PER_UNIT.

From-SVN: r8902

gcc/expr.c

index 6034a46c7de5bbe8d0929e47543622e88106ee36..f810a25b1f8c1a77e25cb1f5dd8120418c0cfc27 100644 (file)
@@ -3070,14 +3070,18 @@ store_constructor (exp, target)
          bitsize = GET_MODE_BITSIZE (mode);
          unsignedp = TREE_UNSIGNED (elttype);
 
-         if (index != 0 && TREE_CODE (index) != INTEGER_CST)
+         if ((index != 0 && TREE_CODE (index) != INTEGER_CST)
+             || TREE_CODE (TYPE_SIZE (elttype)) != INTEGER_CST)
            {
-             /* We don't currently allow variable indices in a
-                C initializer, but let's try here to support them.  */
              rtx pos_rtx, addr, xtarget;
              tree position;
 
-             position = size_binop (MULT_EXPR, index, TYPE_SIZE (elttype));
+             if (index == 0)
+               index = size_int (i);
+
+             position = size_binop (EXACT_DIV_EXPR, TYPE_SIZE (elttype),
+                                    size_int (BITS_PER_UNIT));
+             position = size_binop (MULT_EXPR, index, position);
              pos_rtx = expand_expr (position, 0, VOIDmode, 0);
              addr = gen_rtx (PLUS, Pmode, XEXP (target, 0), pos_rtx);
              xtarget = change_address (target, mode, addr);