From 2364f3f6b083d94cde53180e30901b1c7ed52f1f Mon Sep 17 00:00:00 2001 From: dick Date: Tue, 10 Oct 1989 11:21:55 +0000 Subject: [PATCH] some small corrections in the lint part --- lang/cem/cemcom/ch7.c | 3 ++- lang/cem/cemcom/decspecs.c | 4 +++- lang/cem/cemcom/l_outdef.c | 6 +++--- lang/cem/cemcom/l_states.c | 10 +++++++--- lang/cem/cemcom/statement.g | 3 +++ 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lang/cem/cemcom/ch7.c b/lang/cem/cemcom/ch7.c index cbe52a115..f2c71945f 100644 --- a/lang/cem/cemcom/ch7.c +++ b/lang/cem/cemcom/ch7.c @@ -287,13 +287,14 @@ ch7cast(expp, oper, tp) break; case EQUAL: case NOTEQUAL: + case ':': case '=': case RETURN: if (is_cp_cst(*expp) && (*expp)->VL_VALUE == (arith)0) break; default: expr_warning(*expp, - "illegal conversion of %s to pointer", + "dubious conversion of %s to pointer", symbol2str(oldtp->tp_fund)); break; } diff --git a/lang/cem/cemcom/decspecs.c b/lang/cem/cemcom/decspecs.c index 10a07cd90..4ce4f927d 100644 --- a/lang/cem/cemcom/decspecs.c +++ b/lang/cem/cemcom/decspecs.c @@ -51,8 +51,10 @@ do_decspecs(ds) */ /* some adjustments as described in RM 8.2 */ - if (tp == 0) { + if (tp == 0 && ds->ds_size == 0 && ds->ds_unsigned == 0) { ds->ds_notypegiven = 1; + } + if (tp == 0) { tp = int_type; } switch (ds->ds_size) { diff --git a/lang/cem/cemcom/l_outdef.c b/lang/cem/cemcom/l_outdef.c index ef31a1a89..32338b473 100644 --- a/lang/cem/cemcom/l_outdef.c +++ b/lang/cem/cemcom/l_outdef.c @@ -70,7 +70,7 @@ lint_declare_idf(idf, sc) lint_ext_def(idf, sc) struct idf *idf; { -/* At this place the following fields of the outputdefinition can be +/* At this place the following fields of the output definition can be * filled: * name, stat_number, class, file, line, type. * For variable definitions and declarations this will be all. @@ -163,7 +163,7 @@ lint_formals() switch (type->tp_fund) { case CHAR: case SHORT: - type = int_type; + type = (type->tp_unsigned ? uint_type : int_type); break; case FLOAT: type = double_type; @@ -271,7 +271,7 @@ output_def(od) /* As the types are output the tp_entries are removed, because they * are then not needed anymore. */ - if (od->od_class == XXDF) + if (od->od_class == XXDF || !od->od_name || od->od_name[0] == '#') return; if (LINTLIB) { diff --git a/lang/cem/cemcom/l_states.c b/lang/cem/cemcom/l_states.c index 78c486089..51557affe 100644 --- a/lang/cem/cemcom/l_states.c +++ b/lang/cem/cemcom/l_states.c @@ -150,7 +150,7 @@ lint_1_local(idf, def) if ( (sc == STATIC || sc == LABEL) && !def->df_used ) { - def_warning(def, "%s %s declared but not used in function %s", + def_warning(def, "%s %s not used anywhere in function %s", symbol2str(sc), idf->id_text, func_name); } @@ -359,7 +359,7 @@ check_autos() } else { def_warning(a->ad_def, - "%s neither set nor used in function %s", + "%s not used anywhere in function %s", a->ad_idf->id_text, func_name); } } @@ -751,7 +751,7 @@ start_loop_stmt(looptype, const, cond) dbg_lint_stack("start_loop_stmt"); if (const && !cond) { /* while (0) | for (;0;) */ - hwarning("condition in %s statement is constant", + hwarning("condition in %s statement is always false", symbol2str(looptype)); new->ls_current->st_notreached = 1; } @@ -815,6 +815,10 @@ end_do_stmt(const, cond) register struct lint_stack_entry *lse = find_wdf(); dbg_lint_stack("end_do_stmt"); + if (const && !cond) { + /* do ... while (0) */ + hwarning("condition in do statement is always false"); + } lse->LS_TEST = (!const ? TEST_VAR : cond ? TEST_TRUE : TEST_FALSE); end_loop_stmt(); diff --git a/lang/cem/cemcom/statement.g b/lang/cem/cemcom/statement.g index b8c2cfb99..1967ed39d 100644 --- a/lang/cem/cemcom/statement.g +++ b/lang/cem/cemcom/statement.g @@ -138,6 +138,9 @@ if_statement '(' expression(&expr) { +#ifdef DEBUG + print_expr("expr in IF", expr); +#endif DEBUG opnd2test(&expr, IF); if (is_cp_cst(expr)) { /* The comparison has been optimized -- 2.34.1