(complete_array_type): Handle TREE_PURPOSE of array constructor elements.
authorRichard Stallman <rms@gnu.org>
Mon, 13 Sep 1993 20:17:48 +0000 (20:17 +0000)
committerRichard Stallman <rms@gnu.org>
Mon, 13 Sep 1993 20:17:48 +0000 (20:17 +0000)
From-SVN: r5316

gcc/c-decl.c

index 539828e1c6743fe85d875e207e056ececfd4cbb7..205d5ad8458e0e10280b8154f9b763a2e441bf8a 100644 (file)
@@ -3672,9 +3672,16 @@ complete_array_type (type, initial_value, do_default)
        }
       else if (TREE_CODE (initial_value) == CONSTRUCTOR)
        {
-         register int nelts
-           = list_length (CONSTRUCTOR_ELTS (initial_value));
-         maxindex = build_int_2 (nelts - 1, - (nelts == 0));
+         tree elts = CONSTRUCTOR_ELTS (initial_value);
+         maxindex = integer_zero_node;
+         for (; elts; elts = TREE_CHAIN (elts))
+           {
+             if (TREE_PURPOSE (elts))
+               maxindex = TREE_PURPOSE (elts);
+             else
+               maxindex = size_binop (PLUS_EXPR, maxindex, size_one_node);
+           }
+         maxindex = copy_node (maxindex);
        }
       else
        {