decl.c (layout_chill_variants): Calculate nlables properly.
authorDave Brolley <brolley@cygnus.com>
Mon, 31 Aug 1998 12:35:32 +0000 (12:35 +0000)
committerDave Brolley <brolley@gcc.gnu.org>
Mon, 31 Aug 1998 12:35:32 +0000 (08:35 -0400)
Mon Aug 31 15:35:16 1998  Dave Brolley  <brolley@cygnus.com>
* decl.c (layout_chill_variants): Calculate nlables properly.

From-SVN: r22130

gcc/ch/ChangeLog
gcc/ch/decl.c

index 9c930f5fd69ab8e7bde6362c35c30261825f0839..60bd144aca8077ee30649befb72c6ebc3c7cf987 100644 (file)
@@ -1,3 +1,7 @@
+Mon Aug 31 15:35:16 1998  Dave Brolley  <brolley@cygnus.com>
+
+       * decl.c (layout_chill_variants): Calculate nlables properly.
+
 Mon Jul 27 17:21:01 1998  Dave Brolley  <brolley@cygnus.com>
 
        * typeck.c (apply_chill_array_layout): Don't set TYPE_SIZE of the
index 57842b03984c997444c58ecc86917325a7b03c1f..83e1a053a2a3732ab1be4aff7e78787543838870 100644 (file)
@@ -1690,7 +1690,7 @@ layout_chill_variants (utype)
      tree utype;
 {
   tree first = TYPE_FIELDS (utype);
-  int nlabels = 0, label_index = 0;
+  int nlabels, label_index = 0;
   struct tree_pair *label_value_array;
   tree decl;
   extern int errorcount;
@@ -1746,7 +1746,6 @@ layout_chill_variants (utype)
                    error_with_decl (TYPE_FIELDS (t),
                                     "inconsistent modes between labels and tag field");
                }
-             nlabels++;
            }
        }
       if (tagfields != NULL_TREE)
@@ -1755,6 +1754,21 @@ layout_chill_variants (utype)
        error ("too many tag labels");
     }
 
+  /* Compute the number of labels to be checked for duplicates.  */
+  nlabels = 0;
+  for (decl = first; decl; decl = TREE_CHAIN (decl))
+    {
+      tree t = TREE_TYPE (decl);
+       /* Only one tag (first case_label_list) supported, for now. */
+      tree labellist = TYPE_TAG_VALUES (t);
+      if (labellist)
+       labellist = TREE_VALUE (labellist);
+      
+      for (; labellist != NULL_TREE; labellist = TREE_CHAIN (labellist))
+       if (TREE_CODE (TREE_VALUE (labellist)) == INTEGER_CST)
+         nlabels++;
+    }
+
   /* Check for duplicate label values.  */
   label_value_array = (struct tree_pair *)alloca (nlabels * sizeof (struct tree_pair));
   for (decl = first; decl; decl = TREE_CHAIN (decl))