From b8d6eae3911b5e9cf9b4193e95f55b26911f46de Mon Sep 17 00:00:00 2001 From: eck Date: Thu, 18 Jan 1990 16:58:53 +0000 Subject: [PATCH] fixed bug: tp_up is field in union; be more careful give warning for struct/union declarations in prototypes --- lang/cem/cemcom.ansi/ch3bin.c | 3 +-- lang/cem/cemcom.ansi/dumpidf.c | 4 ++-- lang/cem/cemcom.ansi/main.c | 2 +- lang/cem/cemcom.ansi/proto.c | 25 +++++++++++++++---------- lang/cem/cemcom.ansi/struct.c | 3 +++ 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/lang/cem/cemcom.ansi/ch3bin.c b/lang/cem/cemcom.ansi/ch3bin.c index 9604695b7..b86a00bdd 100644 --- a/lang/cem/cemcom.ansi/ch3bin.c +++ b/lang/cem/cemcom.ansi/ch3bin.c @@ -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; diff --git a/lang/cem/cemcom.ansi/dumpidf.c b/lang/cem/cemcom.ansi/dumpidf.c index af0c70322..965c84818 100644 --- a/lang/cem/cemcom.ansi/dumpidf.c +++ b/lang/cem/cemcom.ansi/dumpidf.c @@ -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; } diff --git a/lang/cem/cemcom.ansi/main.c b/lang/cem/cemcom.ansi/main.c index 292ee2327..9f434e0a5 100644 --- a/lang/cem/cemcom.ansi/main.c +++ b/lang/cem/cemcom.ansi/main.c @@ -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 */ diff --git a/lang/cem/cemcom.ansi/proto.c b/lang/cem/cemcom.ansi/proto.c index 561525ee9..41a7ef56f 100644 --- a/lang/cem/cemcom.ansi/proto.c +++ b/lang/cem/cemcom.ansi/proto.c @@ -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) { diff --git a/lang/cem/cemcom.ansi/struct.c b/lang/cem/cemcom.ansi/struct.c index 68e7336f6..2aac4a0eb 100644 --- a/lang/cem/cemcom.ansi/struct.c +++ b/lang/cem/cemcom.ansi/struct.c @@ -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; -- 2.34.1