From 058ebd7ee688d8efe6f3d7c2b299a514cda225c2 Mon Sep 17 00:00:00 2001 From: Dave Brolley Date: Mon, 31 Aug 1998 12:35:32 +0000 Subject: [PATCH] decl.c (layout_chill_variants): Calculate nlables properly. Mon Aug 31 15:35:16 1998 Dave Brolley * decl.c (layout_chill_variants): Calculate nlables properly. From-SVN: r22130 --- gcc/ch/ChangeLog | 4 ++++ gcc/ch/decl.c | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/gcc/ch/ChangeLog b/gcc/ch/ChangeLog index 9c930f5fd69..60bd144aca8 100644 --- a/gcc/ch/ChangeLog +++ b/gcc/ch/ChangeLog @@ -1,3 +1,7 @@ +Mon Aug 31 15:35:16 1998 Dave Brolley + + * decl.c (layout_chill_variants): Calculate nlables properly. + Mon Jul 27 17:21:01 1998 Dave Brolley * typeck.c (apply_chill_array_layout): Don't set TYPE_SIZE of the diff --git a/gcc/ch/decl.c b/gcc/ch/decl.c index 57842b03984..83e1a053a2a 100644 --- a/gcc/ch/decl.c +++ b/gcc/ch/decl.c @@ -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))