struct expr *expr;
{
switch (expr->ex_class) {
+ int oper;
case Oper:
- switch (expr->OP_OPER) {
+ oper = expr->OP_OPER;
+ switch (oper) {
case '=':
case TIMESAB:
case DIVAB:
case '(':
case '?':
case ',':
+ oper = 0; /* ignore the ignoring */
break;
case PLUSAB:
case POSTDECR:
case PLUSPLUS:
case MINMIN:
- /* may hide the operator '*' */
+ oper = 0; /* ignore in priciple */
+ /* may, however, hide the operator '*' */
if ( /* operation on a pointer */
expr->OP_TYPE->tp_fund == POINTER
&& /* the result is dereferenced, e.g. *p++; */
expr->ex_type == expr->OP_TYPE->tp_up
) {
- hwarning("result of * ignored");
+ oper = '*';
}
break;
- default:
- hwarning("result of %s ignored",
- symbol2str(expr->OP_OPER));
+ case '/':
+ /* this is a specially weird case: the '/' may
+ result from pointer subtraction
+ */
+ if ( expr->OP_TYPE->tp_fund == INT
+ && expr->OP_LEFT->OP_OPER == '-'
+ && expr->OP_LEFT->OP_TYPE->tp_fund == POINTER
+ ) {
+ oper = '-';
+ }
break;
}
+ if (oper) {
+ hwarning("result of %s ignored", symbol2str(oper));
+ }
break;
case Value:
&& !def->df_used
&& !is_anon_idf(idf)
) {
- def_warning(def, "%s %s not used anywhere in function %s",
+ def_warning(def, "%s %s not applied anywhere in function %s",
symbol2str(sc), idf->id_text, func_name);
}
case USED:
if (!a->ad_set) {
if (!is_anon_idf(idf)) {
- warning("%s%s uninitialized", idf->id_text,
+ warning("variable %s%s uninitialized",
+ idf->id_text,
(a->ad_maybe_set ? " possibly" : "")
);
}
a = new_auto_def();
a->ad_idf = idf;
- a->ad_def = idf->id_def;
+ a->ad_def = def;
a->ad_used = def->df_used;
a->ad_set = def->df_set;
ASSERT(!(a && a->ad_def->df_level > level));
while (a && a->ad_def->df_level == level) {
- if (!a->ad_used && !is_anon_idf(a->ad_idf)) {
- if (a->ad_set || a->ad_maybe_set) {
- def_warning(a->ad_def,
+ struct idf *idf = a->ad_idf;
+ struct def *def = idf->id_def;
+
+ if (!def->df_used && !is_anon_idf(idf)) {
+ if (def->df_set || a->ad_maybe_set) {
+ def_warning(def,
"%s set but not used in function %s",
- a->ad_idf->id_text, func_name);
+ idf->id_text, func_name);
}
else {
- def_warning(a->ad_def,
+ def_warning(def,
"%s not used anywhere in function %s",
- a->ad_idf->id_text, func_name);
+ idf->id_text, func_name);
}
}
#ifdef DEBUG
/* FOR DEBUGGING */
+PRIVATE
+print_autos(a)
+ struct auto_def *a;
+{
+ while (a) {
+ struct idf *idf = a->ad_idf;
+ struct def *def = idf->id_def;
+
+ print("%s", idf->id_text);
+ print("(lvl=%d)", a->ad_def->df_level);
+ print("(u%ds%dm%d U%dS%d) ",
+ a->ad_used, a->ad_set, a->ad_maybe_set,
+ def->df_used, def->df_set
+ );
+ a = a->next;
+ }
+}
+
PRIVATE
pr_lint_state(nm, st)
char *nm;
while (lse) {
print(" |-------------- level %d ------------\n",
lse->ls_level);
- pr_lint_state(" |cur", lse->ls_current);
+ pr_lint_state(" |current", lse->ls_current);
print(" |class == %s\n",
lse->ls_class ? symbol2str(lse->ls_class) : "{");
print(" |--------------\n\n");
}
-print_autos(a)
- register struct auto_def *a;
-{
- while (a) {
- print("%s", a->ad_idf->id_text);
- print("(lvl=%d)", a->ad_def->df_level);
- print("(U%dS%dM%d) ", a->ad_used, a->ad_set, a->ad_maybe_set);
- a = a->next;
- }
-}
#endif DEBUG
#endif LINT