fixed bug: tp_up is field in union; be more careful
authoreck <none@none>
Thu, 18 Jan 1990 16:58:53 +0000 (16:58 +0000)
committereck <none@none>
Thu, 18 Jan 1990 16:58:53 +0000 (16:58 +0000)
give warning for struct/union declarations in prototypes

lang/cem/cemcom.ansi/ch3bin.c
lang/cem/cemcom.ansi/dumpidf.c
lang/cem/cemcom.ansi/main.c
lang/cem/cemcom.ansi/proto.c
lang/cem/cemcom.ansi/struct.c

index 9604695..b86a00b 100644 (file)
@@ -85,8 +85,7 @@ ch3bin(expp, oper, expr)
                                        *expp, '(', (struct expr *)0);
                }
                else
-                       *expp = new_oper(expp_tp->tp_up,
-                                       *expp, '(', expr);
+                       *expp = new_oper(expp_tp->tp_up, *expp, '(', expr);
                (*expp)->ex_flags |= EX_SIDEEFFECTS;
                break;
 
index af0c703..965c848 100644 (file)
@@ -325,7 +325,7 @@ dump_type(tp)
                        ops = 0;
                        break;
                }
-               tp = tp->tp_up;
+               if (!ops) tp = tp->tp_up;
        }
        dumplevel--;
 }
@@ -379,7 +379,7 @@ type2str(tp)
                        ops = 0;
                        break;
                }
-               tp = tp->tp_up;
+               if (!ops) tp = tp->tp_up;
        }
        return buf;
 }
index 292ee23..9f434e0 100644 (file)
@@ -184,7 +184,7 @@ compile(argc, argv)
                FileName = source = argv[0];
        else {
                source = 0;
-               FileName = "standard input";
+               FileName = Salloc("standard input", 16);
        }
 
        if (!InsertFile(source, (char **) 0, &result)) /* read the source file  */
index 561525e..41a7ef5 100644 (file)
@@ -160,8 +160,13 @@ struct type *tp;
 struct idf **idpp;
 {
        struct tag *tg = (struct tag *)0;
+       register int fund = tp->tp_fund;
 
-       while (tp->tp_up) tp = tp->tp_up;
+        while (fund == FIELD || fund == POINTER
+                || fund == ARRAY || fund == FUNCTION) {
+                tp = tp->tp_up;
+                fund = tp->tp_fund;
+        }
        *idpp = tp->tp_idf;
        switch(tp->tp_fund) {
        case ENUM: tg = tp->tp_idf->id_enum; break;
@@ -271,12 +276,8 @@ update_proto(tp, otp)
        */
        register struct proto *pl, *opl;
 
-       if (tp == otp) {
-               return;
-       }
-       if (!tp || !otp) {
-               return;
-       }
+       if (tp == otp) return;
+       if (!tp || !otp) return;
 
        while (tp->tp_fund != FUNCTION) {
                tp = tp->tp_up;
@@ -298,7 +299,6 @@ update_proto(tp, otp)
        } else if (opl) {
                /* old decl has type */
        } else if (pl) {
-               /* new decl has type */
                otp->tp_proto = pl;
        }
 
@@ -309,7 +309,7 @@ free_proto_list(pl)
        register struct proto *pl;
 {
        while (pl) {
-               struct proto *tmp = pl->next;
+               register struct proto *tmp = pl->next;
                free_proto(pl);
                pl = tmp;
        }
@@ -323,8 +323,13 @@ struct type *tp;
 {
        register struct idf *ident;
        register struct tag *tgp, **tgpp;
+       register int fund = tp->tp_fund;
 
-       while(tp->tp_up) tp = tp->tp_up;
+       while (fund == FIELD || fund == POINTER
+               || fund == ARRAY || fund == FUNCTION) {
+               tp = tp->tp_up;
+               fund = tp->tp_fund;
+       }
 
        ident = tp->tp_idf;
        switch (tp->tp_fund) {
index 68e7336..2aac4a0 100644 (file)
@@ -212,6 +212,9 @@ declare_struct(fund, idf, tpp)
        else    {
                /* The struct is new. */
                /* Hook in a new struct tag */
+               if (level <= L_PROTO)
+                       warning("declaration of %s-tag inside parameter list",
+                                   symbol2str(fund));
                tg = new_tag();
                tg->next = *tgp;
                *tgp = tg;