(complete_array_type): Call change_main_variant.
authorRichard Stallman <rms@gnu.org>
Tue, 11 May 1993 04:37:41 +0000 (04:37 +0000)
committerRichard Stallman <rms@gnu.org>
Tue, 11 May 1993 04:37:41 +0000 (04:37 +0000)
(complete_array_type): Make maxindex -1 for empty constructor.

From-SVN: r4417

gcc/c-decl.c

index fa7d5bc567ecfb11c0586cfc951f3a7fce21d05e..5fb9dd60510bc26b81614ad2a8cc3bbbc5bb4f7e 100644 (file)
@@ -3632,7 +3632,7 @@ complete_array_type (type, initial_value, do_default)
        {
          register int nelts
            = list_length (CONSTRUCTOR_ELTS (initial_value));
-         maxindex = build_int_2 (nelts - 1, 0);
+         maxindex = build_int_2 (nelts - 1, - (nelts == 0));
        }
       else
        {
@@ -3654,9 +3654,13 @@ complete_array_type (type, initial_value, do_default)
 
   if (maxindex)
     {
+      tree main;
       TYPE_DOMAIN (type) = build_index_type (maxindex);
       if (!TREE_TYPE (maxindex))
        TREE_TYPE (maxindex) = TYPE_DOMAIN (type);
+      change_main_variant (type,
+                          build_array_type (TREE_TYPE (type),
+                                            TYPE_DOMAIN (type)));
     }
 
   /* Lay out the type now that we can get the real answer.  */