From: ceriel Date: Tue, 26 Mar 1991 09:45:20 +0000 (+0000) Subject: Fix: prevent incorrect error messages X-Git-Tag: release-5-5~1155 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=3e16cf511602a6eeb5cba30da0a280138315f692;p=ack.git Fix: prevent incorrect error messages --- diff --git a/lang/cem/cemcom.ansi/ch3.c b/lang/cem/cemcom.ansi/ch3.c index 14135e21d..537c7eaf6 100644 --- a/lang/cem/cemcom.ansi/ch3.c +++ b/lang/cem/cemcom.ansi/ch3.c @@ -230,7 +230,7 @@ ch3cast(expp, oper, tp) break; } - if (equal_type(tp, oldtp, qual_lev)) { + if (equal_type(tp, oldtp, qual_lev, 0)) { /* life is easy */ if (ascompat && tp->tp_fund == POINTER) { if ((tp->tp_up->tp_typequal & oldtp->tp_up->tp_typequal) @@ -408,9 +408,9 @@ ch3cast(expp, oper, tp) /* Determine whether two types are equal. */ -equal_type(tp, otp, qual_lev) +equal_type(tp, otp, qual_lev, diag) register struct type *tp, *otp; - int qual_lev; + int qual_lev, diag; { if (tp == otp) return 1; @@ -426,9 +426,8 @@ equal_type(tp, otp, qual_lev) return 0; } - if (qual_lev >= 0) { - if (tp->tp_typequal != otp->tp_typequal) - strict("illegal qualifiers"); + if (qual_lev >= 0 && tp->tp_typequal != otp->tp_typequal) { + strict("illegal qualifiers"); } switch (tp->tp_fund) { @@ -439,13 +438,13 @@ equal_type(tp, otp, qual_lev) is the composite type of the corresponding paramaters. */ if (tp->tp_proto && otp->tp_proto) { - if (!equal_proto(tp->tp_proto, otp->tp_proto)) + if (!equal_proto(tp->tp_proto, otp->tp_proto, diag)) return 0; } else if (tp->tp_proto || otp->tp_proto) { - if (!legal_mixture(tp, otp)) + if (!legal_mixture(tp, otp, diag)) return 0; } - return equal_type(tp->tp_up, otp->tp_up, qual_lev + 1); + return equal_type(tp->tp_up, otp->tp_up, qual_lev + 1, diag); case ARRAY: /* If one type is an array of known size, the composite @@ -454,13 +453,13 @@ equal_type(tp, otp, qual_lev) if (tp->tp_size != otp->tp_size && (tp->tp_size != -1 && otp->tp_size != -1)) return 0; - return equal_type(tp->tp_up, otp->tp_up, qual_lev); /* ??? +1 */ + return equal_type(tp->tp_up, otp->tp_up, qual_lev/* ??? +1 */, diag); case POINTER: - return equal_type(tp->tp_up, otp->tp_up, qual_lev + 1); + return equal_type(tp->tp_up, otp->tp_up, qual_lev + 1, diag); case FIELD: - return equal_type(tp->tp_up, otp->tp_up, qual_lev); /* ??? +1 */ + return equal_type(tp->tp_up, otp->tp_up, qual_lev/* ??? +1 */, diag); case STRUCT: case UNION: @@ -472,44 +471,49 @@ equal_type(tp, otp, qual_lev) } } -check_pseudoproto(pl, opl) +check_pseudoproto(pl, opl, diag) register struct proto *pl, *opl; { int retval = 1; if (pl->pl_flag & PL_ELLIPSIS) { - error("illegal ellipsis terminator"); - pl->pl_flag |= PL_ERRGIVEN; - opl->pl_flag |= PL_ERRGIVEN; + if (diag) { + error("illegal ellipsis terminator"); + pl->pl_flag |= PL_ERRGIVEN; + opl->pl_flag |= PL_ERRGIVEN; + } return 0; } if (opl->pl_flag & PL_VOID) { - if (!(pl->pl_flag & PL_VOID)) + if (diag && !(pl->pl_flag & PL_VOID)) strict("function is defined without parameters"); return 0; } while (pl && opl) { - if (!equal_type(pl->pl_type, opl->pl_type, -1)) { - if (!(pl->pl_flag & PL_ERRGIVEN) - && !(opl->pl_flag & PL_ERRGIVEN)) - error("incorrect type for parameter %s of definition", - opl->pl_idf->id_text); - pl->pl_flag |= PL_ERRGIVEN; - opl->pl_flag |= PL_ERRGIVEN; + if (!equal_type(pl->pl_type, opl->pl_type, -1, diag)) { + if (diag) { + if (!(pl->pl_flag & PL_ERRGIVEN) + && !(opl->pl_flag & PL_ERRGIVEN)) + error("incorrect type for parameter %s of definition", + opl->pl_idf->id_text); + pl->pl_flag |= PL_ERRGIVEN; + opl->pl_flag |= PL_ERRGIVEN; + } retval = 0; } pl = pl->next; opl = opl->next; } if (pl || opl) { - error("incorrect number of parameters"); + if (diag) error("incorrect number of parameters"); retval = 0; } return retval; } -legal_mixture(tp, otp) +legal_mixture(tp, otp, diag) struct type *tp, *otp; + int diag; { register struct proto *pl = tp->tp_proto, *opl = otp->tp_proto; int retval = 1; @@ -523,11 +527,11 @@ legal_mixture(tp, otp) prot = opl; } if (!opl && otp->tp_pseudoproto) { - return check_pseudoproto(tp->tp_proto, otp->tp_pseudoproto); + return check_pseudoproto(tp->tp_proto, otp->tp_pseudoproto, diag); } if (prot->pl_flag & PL_ELLIPSIS) { - if (!(prot->pl_flag & PL_ERRGIVEN)) { + if (diag && !(prot->pl_flag & PL_ERRGIVEN)) { if (pl) error("illegal ellipsis terminator"); else error("ellipsis terminator in previous (prototype) declaration"); @@ -539,7 +543,7 @@ legal_mixture(tp, otp) /* if (!(prot->pl_flag & PL_ELLIPSIS)) {} */ fund = prot->pl_type->tp_fund; if (fund == CHAR || fund == SHORT || fund == FLOAT) { - if (!(prot->pl_flag & PL_ERRGIVEN)) + if (diag && !(prot->pl_flag & PL_ERRGIVEN)) error("illegal %s parameter in %sdeclaration", symbol2str(fund), (opl ? "previous (prototype) " : "" )); prot->pl_flag |= PL_ERRGIVEN; @@ -550,8 +554,9 @@ legal_mixture(tp, otp) return retval; } -equal_proto(pl, opl) +equal_proto(pl, opl, diag) register struct proto *pl, *opl; + int diag; { if (pl == opl) return 1; @@ -563,7 +568,7 @@ equal_proto(pl, opl) while ( pl && opl) { if ((pl->pl_flag & ~PL_ERRGIVEN) != (opl->pl_flag & ~PL_ERRGIVEN) || - !equal_type(pl->pl_type, opl->pl_type, -1)) + !equal_type(pl->pl_type, opl->pl_type, -1, diag)) return 0; pl = pl->next; diff --git a/lang/cem/cemcom.ansi/ch3bin.c b/lang/cem/cemcom.ansi/ch3bin.c index ce78205ad..713e42efb 100644 --- a/lang/cem/cemcom.ansi/ch3bin.c +++ b/lang/cem/cemcom.ansi/ch3bin.c @@ -239,7 +239,7 @@ ch3bin(expp, oper, expr) case ':': if (is_struct_or_union(expp_tp->tp_fund) || is_struct_or_union(expr->ex_type->tp_fund)) { - if (!equal_type(expp_tp, expr->ex_type, -1)) + if (!equal_type(expp_tp, expr->ex_type, -1, 0)) expr_error(*expp, "illegal balance"); } else @@ -292,7 +292,7 @@ pntminuspnt(expp, oper, expr) */ struct type *up_type = (*expp)->ex_type->tp_up; - if (!equal_type(up_type, expr->ex_type->tp_up, -1)) { + if (!equal_type(up_type, expr->ex_type->tp_up, -1, 0)) { expr_error(*expp, "subtracting incompatible pointers"); free_expression(expr); erroneous2int(expp); diff --git a/lang/cem/cemcom.ansi/declar.g b/lang/cem/cemcom.ansi/declar.g index 4cd60900e..ae79dc523 100644 --- a/lang/cem/cemcom.ansi/declar.g +++ b/lang/cem/cemcom.ansi/declar.g @@ -265,7 +265,7 @@ initializer(struct idf *idf; int sc;) #endif LINT #ifdef DBSYMTAB if (options['g'] && level >= L_LOCAL && expr) { - db_line(expr->ex_file, (int) expr->ex_line); + db_line(expr->ex_file, (unsigned) expr->ex_line); } #endif /* DBSYMTAB */ if (autoagg) diff --git a/lang/cem/cemcom.ansi/idf.c b/lang/cem/cemcom.ansi/idf.c index 901082b25..cf85bf7f5 100644 --- a/lang/cem/cemcom.ansi/idf.c +++ b/lang/cem/cemcom.ansi/idf.c @@ -409,7 +409,7 @@ global_redecl(idf, new_sc, tp) register struct def *def = idf->id_def; while (def->df_level != L_GLOBAL) def = def->next; - if (!equal_type(tp, def->df_type, 0)) { + if (!equal_type(tp, def->df_type, 0, 0)) { error("redeclaration of %s with different type", idf->id_text); return; } else update_proto(tp, def->df_type); @@ -592,7 +592,7 @@ check_formals(idf, dc) } while(fm && pl) { if (!equal_type(promoted_type(fm->fm_idf->id_def->df_type) - , pl->pl_type, -1)) { + , pl->pl_type, -1, 1)) { if (!(pl->pl_flag & PL_ERRGIVEN)) error("incorrect type for parameter %s" , fm->fm_idf->id_text); diff --git a/lang/cem/cemcom.ansi/struct.c b/lang/cem/cemcom.ansi/struct.c index 5d8c50d61..345ac010c 100644 --- a/lang/cem/cemcom.ansi/struct.c +++ b/lang/cem/cemcom.ansi/struct.c @@ -267,7 +267,7 @@ idf2sdef(idf, tp) /* Follow chain from idf, to meet tp. */ while ((sdef = *sdefp)) { - if (equal_type(sdef->sd_stype, tp, -999)) /* ??? hack */ + if (equal_type(sdef->sd_stype, tp, -999, 0)) /* ??? hack */ return sdef; sdefp = &(*sdefp)->next; }