Minix again
authoreck <none@none>
Fri, 20 Oct 1989 13:06:10 +0000 (13:06 +0000)
committereck <none@none>
Fri, 20 Oct 1989 13:06:10 +0000 (13:06 +0000)
lang/cem/cemcom.ansi/BigPars
lang/cem/cemcom.ansi/SmallPars
lang/cem/cemcom.ansi/ch3.c
lang/cem/cemcom.ansi/ch3bin.c
lang/cem/cemcom.ansi/pragma.c
lang/cem/cemcom.ansi/proto.c

index c8c22d3..fb6ecb2 100644 (file)
@@ -21,7 +21,7 @@
 
 
 !File: nparams.h
-#define        NPARAMS 32      /* maximum number of parameters of macros       */
+#define        NPARAMS 32      /* maximum number of parameters                 */
 #define        STDC_NPARAMS 31 /* ANSI limit on number of parameters           */
 
 
index 9ae5e0f..5dcb139 100644 (file)
@@ -21,7 +21,7 @@
 
 
 !File: nparams.h
-#define        NPARAMS 32      /* maximum number of parameters of macros       */
+#define        NPARAMS 32      /* maximum number of parameters                 */
 #define        STDC_NPARAMS 31 /* ANSI limit on number of parameters           */
 
 
index 75ec334..d1ccddf 100644 (file)
@@ -348,7 +348,7 @@ equal_type(tp, otp, check_qual)
            || (tp->tp_unsigned != otp->tp_unsigned)
            || (tp->tp_align != otp->tp_align))
                return 0;
-       if (tp->tp_fund != ARRAY /* && tp->tp_fund != STRUCT */ ) {     /* UNION ??? */
+       if (tp->tp_fund != ARRAY) {
                if (tp->tp_size != otp->tp_size)
                        return 0;
        }
@@ -516,6 +516,7 @@ struct type *tp;
        register struct sdef *sdf;
 
        ASSERT(tp);
+
        if (tp->tp_typequal & TQ_CONST) return 1;
        sdf = tp->tp_sdef;
        while (sdf) {
index 3a12327..4d38012 100644 (file)
@@ -206,7 +206,7 @@ ch3bin(expp, oper, expr)
                                *expp = intexpr((arith)((oper == AND) ? 0 : 1),
                                                INT);
                        }
-                       (*expp)->ex_flags |= ex->ex_flags;
+                       (*expp)->ex_flags |= ex->ex_flags | EX_ILVALUE;
                        free_expression(ex);
                }
                else
@@ -217,7 +217,7 @@ ch3bin(expp, oper, expr)
                                and ((oper == AND) || (oper == OR))
                        */
                        if ((oper == AND) == (expr->VL_VALUE != (arith)0)) {
-                               (*expp)->ex_flags |= expr->ex_flags;
+                               (*expp)->ex_flags |= expr->ex_flags | EX_ILVALUE;
                                free_expression(expr);
                        }
                        else {
@@ -297,7 +297,8 @@ pntminuspnt(expp, oper, expr)
        ch3cast(expp, CAST, pa_type);   /* ptr-ptr: result has pa_type  */
        ch3bin(expp, '/',
                intexpr(size_of_type(up_type, "object"), pa_type->tp_fund));
-       ch3cast(expp, CAST, int_type);  /* result will be an integer expr */
+       ch3cast(expp, CAST, pa_type);   /* result will be an integgral expr */
+                                       /* cast necessary ??? */
 }
 
 mk_binop(expp, oper, expr, commutative)
index 121e86d..7e9ce68 100644 (file)
@@ -29,7 +29,7 @@ struct pkey {
        char *pk_name;
        int pk_key;
 } pragmas[] = {
-       {"flags",       P_FLAGS},
+       {"cemflags",    P_FLAGS},
        {0,             P_UNKNOWN}
 };
 
index a090073..6768e52 100644 (file)
@@ -319,23 +319,26 @@ free_proto_list(pl)
 remove_proto_tag(tp)
 struct type *tp;
 {
-       struct idf *ident;
-       struct tag *tg, *otg = 0;
+       register struct idf *ident;
+       register struct tag *tgp, **tgpp;
 
        while(tp->tp_up) tp = tp->tp_up;
 
        ident = tp->tp_idf;
-       switch(tp->tp_fund) {
-       case ENUM: tg = ident->id_enum; break;
-       case UNION:
-       case STRUCT: tg = ident->id_struct; break;
+       switch (tp->tp_fund) {
+       case ENUM: tgpp = &(ident->id_enum); break;
+       case STRUCT:
+       case UNION: tgpp = &(ident->id_struct); break;
        default: return;
        }
-       while (tg && tg->tg_type != tp) {
-               otg = tg;
-               tg = tg->next;
+
+       while((*tgpp) && (*tgpp)->tg_type != tp) {
+               tgpp = &((*tgpp)->next);
        }
-       if (tg ->tg_level > L_PROTO) return;
+       ASSERT(*tgpp);
+
+       tgp = *tgpp;
+       if (tgp->tg_level > L_PROTO) return;
 
 #ifdef DEBUG
        if (options['t'])
@@ -343,26 +346,15 @@ struct type *tp;
                        ident->id_text);
 #endif
 
-       if (!otg) {
-               switch(tp->tp_fund) {
-               case ENUM: ident->id_enum = tg->next; break;
-               case UNION:
-               case STRUCT: ident->id_struct = tg->next; break;
-               }
-               free_tag(tg);
-       }
-       else {
-               otg->next = tg->next;
-               free_tag(tg);
-       }
+       (*tgpp) = tgp->next;
+       free_tag(tgp);
 }
 
 remove_proto_idfs(pl)
        register struct proto *pl;
 {
        /*      Remove all the identifier definitions from the
-               prototype list. Keep in account the recursive
-               function definitions.
+               prototype list.
        */
        register struct def *def;
 
@@ -372,21 +364,6 @@ remove_proto_idfs(pl)
                        if (options['t'])
                                print("Removing idf %s from list\n",
                                        pl->pl_idf->id_text);
-#endif
-                       /*      Remove all the definitions made within
-                               a prototype.
-                               ??? is this really necessary (Hans)
-                               wasn't this done before in the declaration
-                       */
-#if 0
-                       if (pl->pl_flag & PL_FORMAL) {
-                               register struct type *tp = pl->pl_type;
-
-                               while (tp && tp->tp_fund != FUNCTION)
-                                       tp = tp->tp_up;
-                               if (tp)
-                                   debug("remove_proto_idfs(tp->tp_proto)");
-                       }
 #endif
                        def = pl->pl_idf->id_def;
                        if (def && def->df_level <= L_PROTO){
@@ -417,34 +394,34 @@ call_proto(expp)
        register struct proto *pl = NO_PROTO;
        static struct proto ellipsis = { 0, 0, 0, PL_ELLIPSIS };
 
-       if (left != NILEXPR) {  /* in case of an error */
+       if (left != NILEXPR) {          /* in case of an error */
                register struct type *tp = left->ex_type;
 
                while (tp && tp->tp_fund != FUNCTION)
                        tp = tp->tp_up;
-               pl = (tp && tp->tp_proto) ? tp->tp_proto : NO_PROTO;
+               if (tp && tp->tp_proto)
+                       pl = tp->tp_proto;
        }
 
-       if (right != NILEXPR) { /* function call with parameters */
-               register struct expr *ex = right;
+       if (right != NILEXPR) {         /* function call with parameters */
                register struct expr **ep = &((*expp)->OP_RIGHT);
                register int ecnt = 0, pcnt = 0;
                struct expr **estack[NPARAMS];
                struct proto *pstack[NPARAMS];
 
                /* stack up the parameter expressions */
-               while (ex->ex_class == Oper && ex->OP_OPER == PARCOMMA) {
+               while (right->ex_class == Oper && right->OP_OPER == PARCOMMA) {
                        if (ecnt == STDC_NPARAMS)
                                strict("number of parameters exceeds ANSI limit");
                        if (ecnt >= NPARAMS-1) {
                                error("too many parameters");
                                return;
                        }
-                       estack[ecnt++] = &(ex->OP_RIGHT);
-                       ep = &(ex->OP_LEFT);
-                       ex = ex->OP_LEFT;
+                       estack[ecnt++] = &(right->OP_RIGHT);
+                       ep = &(right->OP_LEFT);
+                       right = right->OP_LEFT;
                }
-               estack[ecnt++] = ep;
+               estack[ecnt] = ep;
 
                /*      Declarations like int f(void) do not expect any
                        parameters.
@@ -456,19 +433,18 @@ call_proto(expp)
 
                /* stack up the prototypes */
                if (pl) {
+                       pcnt--;
                        do {
                                /* stack prototypes */
-                               pstack[pcnt++] = pl;
+                               pstack[++pcnt] = pl;
                                pl = pl->next;
                        } while (pl);
-                       pcnt--;
                }
                else {
-                       pcnt = 0;
                        pstack[0] = &ellipsis;
                }
 
-               for (--ecnt; ecnt >= 0; ecnt--) {
+               for (ecnt; ecnt >= 0; ecnt--) {
                        /*      Only the parameters specified in the prototype
                                are checked and converted. The parameters that
                                fall under the ellipsis clause are neither