From aa4de95f26e3d876edd52854b5cb7ea000a4a6b0 Mon Sep 17 00:00:00 2001 From: eck Date: Fri, 6 Apr 1990 15:37:16 +0000 Subject: [PATCH] various bug fixes & improvements --- lang/cem/cemcom.ansi/ch3.c | 2 +- lang/cem/cemcom.ansi/ch3mon.c | 5 ++--- lang/cem/cemcom.ansi/dumpidf.c | 3 ++- lang/cem/cemcom.ansi/idf.c | 13 ++++++++----- lang/cem/cemcom.ansi/proto.c | 6 +++++- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lang/cem/cemcom.ansi/ch3.c b/lang/cem/cemcom.ansi/ch3.c index 6803fc8a6..bfe03f15c 100644 --- a/lang/cem/cemcom.ansi/ch3.c +++ b/lang/cem/cemcom.ansi/ch3.c @@ -612,7 +612,7 @@ ch3asgn(expp, oper, expr) expr_error(exp, "operand of %s is read-only", oper_string); } else if (fund == STRUCT || fund == UNION) { if (recurqual(exp->ex_type, TQ_CONST)) - expr_error(expr,"operand of %s contains a const-qualified member", + expr_error(exp,"operand of %s contains a const-qualified member", oper_string); } diff --git a/lang/cem/cemcom.ansi/ch3mon.c b/lang/cem/cemcom.ansi/ch3mon.c index fc82a4585..08a2fc4fe 100644 --- a/lang/cem/cemcom.ansi/ch3mon.c +++ b/lang/cem/cemcom.ansi/ch3mon.c @@ -42,9 +42,8 @@ ch3mon(oper, expp) symbol2str((*expp)->ex_type->tp_fund)); } else { expr = *expp; - if ((expr->ex_type->tp_fund == ARRAY - && expr->ex_class != String) - || expr->ex_type->tp_fund == FUNCTION) + + if (is_ld_cst(expr)) /* dereference in administration only */ expr->ex_type = expr->ex_type->tp_up; else /* runtime code */ diff --git a/lang/cem/cemcom.ansi/dumpidf.c b/lang/cem/cemcom.ansi/dumpidf.c index 9c55d202f..fc5ee2249 100644 --- a/lang/cem/cemcom.ansi/dumpidf.c +++ b/lang/cem/cemcom.ansi/dumpidf.c @@ -255,7 +255,8 @@ dump_proto(pl) print("%d: %s", argcnt++, pl->pl_flag & PL_FORMAL ? (pl->pl_flag & PL_VOID ? "void" : "formal") - : "ellipsis"); + : (pl->pl_flag & PL_ELLIPSIS + ? "ellipsis" : "unknown" )); newline(); if (type = pl->pl_type){ dump_type(type); diff --git a/lang/cem/cemcom.ansi/idf.c b/lang/cem/cemcom.ansi/idf.c index f01832af0..5d4b64a01 100644 --- a/lang/cem/cemcom.ansi/idf.c +++ b/lang/cem/cemcom.ansi/idf.c @@ -597,11 +597,10 @@ check_formals(idf, dc) if (du->du_proto) return; - if (!options['o']) - warning("'%s' old-fashioned function definition" - , dc->dc_idf->id_text); - if (pl) { + /* Don't give a warning about an old-style definition, + * since the arguments will be checked anyway. + */ if (pl->pl_flag & PL_ELLIPSIS) { if (!(du->du_proto) && !(pl->pl_flag & PL_ERRGIVEN)) error("ellipsis terminator in previous declaration"); @@ -627,6 +626,10 @@ check_formals(idf, dc) } else { /* make a pseudo-prototype */ register struct proto *lpl = new_proto(); + if (!options['o']) + warning("'%s' old-fashioned function definition" + , dc->dc_idf->id_text); + while (fm) { if (pl == 0) pl = lpl; else { @@ -642,7 +645,7 @@ check_formals(idf, dc) if (pl == 0) { /* make func(void) */ pl = lpl; pl->pl_type = void_type; - pl->pl_flag = PL_VOID; + pl->pl_flag = PL_FORMAL | PL_VOID; } idf->id_def->df_type->tp_pseudoproto = pl; } diff --git a/lang/cem/cemcom.ansi/proto.c b/lang/cem/cemcom.ansi/proto.c index 41a7ef56f..2f706a8bd 100644 --- a/lang/cem/cemcom.ansi/proto.c +++ b/lang/cem/cemcom.ansi/proto.c @@ -79,7 +79,9 @@ add_proto(pl, ds, dc, lvl) else { if (idf != (struct idf *)0) error("illegal use of void in argument list"); - else pl->pl_flag = PL_VOID; + else { + pl->pl_flag |= PL_VOID; + } } } @@ -280,6 +282,7 @@ update_proto(tp, otp) if (!tp || !otp) return; while (tp->tp_fund != FUNCTION) { + if (tp->tp_fund != POINTER && tp->tp_fund != ARRAY) return; tp = tp->tp_up; otp = otp->tp_up; if (!tp) return; @@ -287,6 +290,7 @@ update_proto(tp, otp) pl = tp->tp_proto; opl = otp->tp_proto; + if (pl == opl) return; if (pl && opl) { /* both have prototypes */ while (pl && opl) { -- 2.34.1