fix in reference counts for sets
authorceriel <none@none>
Tue, 20 Oct 1987 13:32:18 +0000 (13:32 +0000)
committerceriel <none@none>
Tue, 20 Oct 1987 13:32:18 +0000 (13:32 +0000)
lang/m2/comp/chk_expr.c
lang/m2/comp/cstoper.c

index 9a8c880..2ee76d1 100644 (file)
@@ -311,11 +311,6 @@ ChkExLinkOrName(expp)
        if (df->df_kind & (D_ENUM | D_CONST)) {
                /* Replace an enum-literal or a CONST identifier by its value.
                */
-               if (df->df_type->tp_fund == T_SET) {
-                       expp->nd_class = Set;
-                       inc_refcount(expp->nd_set);
-               }
-               else    expp->nd_class = Value;
                if (df->df_kind == D_ENUM) {
                        expp->nd_INT = df->enm_val;
                        expp->nd_symb = INTEGER;
@@ -327,6 +322,11 @@ ChkExLinkOrName(expp)
                        expp->nd_token = df->con_const;
                        expp->nd_lineno = ln;
                }
+               if (df->df_type->tp_fund == T_SET) {
+                       expp->nd_class = Set;
+                       inc_refcount(expp->nd_set);
+               }
+               else    expp->nd_class = Value;
        }
 
        if (!(df->df_kind & D_VALUE)) {
@@ -426,7 +426,7 @@ MkSet(size)
 {
        register arith  *s;
 
-       size = ((size + (int)word_size - 1) / (int)word_size + 1) * sizeof(arith);
+       size = (size / (int) word_size + 1) * sizeof(arith);
        s = (arith *) Malloc(size);
        clear((char *) s , size);
        s++;
@@ -439,6 +439,7 @@ FreeSet(s)
 {
        dec_refcount(s);
        if (refcount(s) <= 0) {
+               assert(refcount(s) == 0);
                free((char *) (s-1));
        }
 }
index f75fdac..27b67ae 100644 (file)
@@ -251,7 +251,7 @@ cstset(expp)
        assert(expp->nd_symb == IN || expp->nd_left->nd_class == Set);
 
        set2 = expp->nd_right->nd_set;
-       setsize = (unsigned) expp->nd_right->nd_type->tp_size / (unsigned) word_size;
+       setsize = (unsigned) (expp->nd_right->nd_type->tp_size) / (unsigned) word_size;
 
        if (expp->nd_symb == IN) {
                unsigned i;