some small corrections in the lint part

This commit is contained in:
dick 1989-10-10 11:21:55 +00:00
parent 9715c40c3f
commit 2364f3f6b0
5 changed files with 18 additions and 8 deletions

View file

@ -287,13 +287,14 @@ ch7cast(expp, oper, tp)
break; break;
case EQUAL: case EQUAL:
case NOTEQUAL: case NOTEQUAL:
case ':':
case '=': case '=':
case RETURN: case RETURN:
if (is_cp_cst(*expp) && (*expp)->VL_VALUE == (arith)0) if (is_cp_cst(*expp) && (*expp)->VL_VALUE == (arith)0)
break; break;
default: default:
expr_warning(*expp, expr_warning(*expp,
"illegal conversion of %s to pointer", "dubious conversion of %s to pointer",
symbol2str(oldtp->tp_fund)); symbol2str(oldtp->tp_fund));
break; break;
} }

View file

@ -51,8 +51,10 @@ do_decspecs(ds)
*/ */
/* some adjustments as described in RM 8.2 */ /* 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; ds->ds_notypegiven = 1;
}
if (tp == 0) {
tp = int_type; tp = int_type;
} }
switch (ds->ds_size) { switch (ds->ds_size) {

View file

@ -70,7 +70,7 @@ lint_declare_idf(idf, sc)
lint_ext_def(idf, sc) lint_ext_def(idf, sc)
struct idf *idf; 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: * filled:
* name, stat_number, class, file, line, type. * name, stat_number, class, file, line, type.
* For variable definitions and declarations this will be all. * For variable definitions and declarations this will be all.
@ -163,7 +163,7 @@ lint_formals()
switch (type->tp_fund) { switch (type->tp_fund) {
case CHAR: case CHAR:
case SHORT: case SHORT:
type = int_type; type = (type->tp_unsigned ? uint_type : int_type);
break; break;
case FLOAT: case FLOAT:
type = double_type; type = double_type;
@ -271,7 +271,7 @@ output_def(od)
/* As the types are output the tp_entries are removed, because they /* As the types are output the tp_entries are removed, because they
* are then not needed anymore. * are then not needed anymore.
*/ */
if (od->od_class == XXDF) if (od->od_class == XXDF || !od->od_name || od->od_name[0] == '#')
return; return;
if (LINTLIB) { if (LINTLIB) {

View file

@ -150,7 +150,7 @@ lint_1_local(idf, def)
if ( (sc == STATIC || sc == LABEL) if ( (sc == STATIC || sc == LABEL)
&& !def->df_used && !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); symbol2str(sc), idf->id_text, func_name);
} }
@ -359,7 +359,7 @@ check_autos()
} }
else { else {
def_warning(a->ad_def, 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); a->ad_idf->id_text, func_name);
} }
} }
@ -751,7 +751,7 @@ start_loop_stmt(looptype, const, cond)
dbg_lint_stack("start_loop_stmt"); dbg_lint_stack("start_loop_stmt");
if (const && !cond) { if (const && !cond) {
/* while (0) | for (;0;) */ /* while (0) | for (;0;) */
hwarning("condition in %s statement is constant", hwarning("condition in %s statement is always false",
symbol2str(looptype)); symbol2str(looptype));
new->ls_current->st_notreached = 1; new->ls_current->st_notreached = 1;
} }
@ -815,6 +815,10 @@ end_do_stmt(const, cond)
register struct lint_stack_entry *lse = find_wdf(); register struct lint_stack_entry *lse = find_wdf();
dbg_lint_stack("end_do_stmt"); 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); lse->LS_TEST = (!const ? TEST_VAR : cond ? TEST_TRUE : TEST_FALSE);
end_loop_stmt(); end_loop_stmt();

View file

@ -138,6 +138,9 @@ if_statement
'(' '('
expression(&expr) expression(&expr)
{ {
#ifdef DEBUG
print_expr("expr in IF", expr);
#endif DEBUG
opnd2test(&expr, IF); opnd2test(&expr, IF);
if (is_cp_cst(expr)) { if (is_cp_cst(expr)) {
/* The comparison has been optimized /* The comparison has been optimized