2 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3 * See the copyright notice in the ACK home directory, in the file "Copyright".
5 /* $Id: l_states.c,v 1.10 1994/06/27 08:01:14 ceriel Exp $ */
6 /* Lint status checking */
12 #include <alloc.h> /* for st_free */
13 #include "interface.h"
17 #include <flt_arith.h>
24 #include "code.h" /* RVAL etc */
33 #include "l_comment.h"
37 #define dbg_lint_stack(m) /*print_lint_stack(m) /* or not */
39 #define dbg_lint_stack(m)
42 extern char *symbol2str();
43 extern char *func_name;
44 extern struct type *func_type;
45 extern int func_notypegiven;
46 extern char loptions[];
47 extern struct stack_level *local_level;
49 /* global variables for the lint_stack */
50 PRIVATE struct lint_stack_entry *top_ls;
52 /* global variables for the brace stack */
53 PRIVATE int brace_count;
54 PRIVATE struct brace *top_br;
56 /* global variables for the function return */
57 PRIVATE int valreturned; /* see l_lint.h */
58 PRIVATE int return_warned;
61 PRIVATE lint_1_local();
62 PRIVATE lint_1_global();
63 PRIVATE start_loop_stmt();
64 PRIVATE check_autos();
65 PRIVATE struct auto_def *copy_auto_list();
66 PRIVATE free_auto_list();
67 PRIVATE struct state *copy_state();
69 PRIVATE remove_settings();
70 PRIVATE struct auto_def *merge_autos();
71 PRIVATE merge_states();
72 PRIVATE struct lint_stack_entry *find_wdf(), *find_wdfc(), *find_cs();
74 PRIVATE break_merge();
75 PRIVATE struct lint_stack_entry *mk_lint_stack_entry();
81 /* Allocate memory for the global lint-stack elements.
83 top_ls = new_lint_stack_entry();
84 top_ls->ls_current = new_state();
89 register struct brace *br = new_brace();
91 dbg_lint_stack("lint_start_local");
93 br->br_count = brace_count;
100 struct stack_level *stl;
103 dbg_lint_stack("lint_end_local");
105 top_ls->ls_current->st_notreached = 1;
106 top_ls->ls_current->st_warned = 0;
110 if (top_ls->ls_class == CASE && level == top_ls->ls_level) {
111 /* supply missing break; at end of switch */
121 struct stack_level *stl;
123 /* Check if static variables and labels are used and/or set.
124 Automatic vars have already been checked by check_autos().
126 register struct stack_entry *se = stl->sl_entry;
127 register struct brace *br;
130 register struct idf *idf = se->se_idf;
133 lint_1_local(idf, idf->id_def);
135 if (stl->sl_level == L_LOCAL && idf->id_label) {
136 lint_1_local(idf, idf->id_label);
141 /* remove entry from brace stack */
148 lint_1_local(idf, def)
152 register int sc = def->df_sc;
154 if ( (sc == STATIC || sc == LABEL)
158 def_warning(def, "%s %s not applied anywhere in function %s",
159 symbol2str(sc), idf->id_text, func_name);
164 && !def->df_initialized
165 && def->df_firstbrace != 0
166 && def->df_minlevel != level
169 register int diff = def->df_minlevel - level;
172 "local %s could be declared %d level%s deeper",
173 idf->id_text, diff, (diff == 1 ? "" : "s")
179 struct stack_level *stl;
181 register struct stack_entry *se = stl->sl_entry;
183 dbg_lint_stack("lint_end_global");
184 ASSERT(level == L_GLOBAL);
186 register struct idf *idf = se->se_idf;
187 register struct def *def = idf->id_def;
190 lint_1_global(idf, def);
197 lint_1_global(idf, def)
201 register int sc = def->df_sc;
202 register struct type *tp = def->df_type;
203 register int fund = tp->tp_fund;
211 #endif /* IMPLICIT */
212 if (fund == ERRONEOUS)
215 if (fund == FUNCTION && sc != STATIC) {
216 output_proto(idf, def);
219 if (def->df_set || def->df_used) {
220 /* Output a line to the intermediate file for
221 * used external variables (including functions)
226 if (sc == STATIC && !def->df_used) {
228 if (!is_anon_idf(idf) && fund != ERRONEOUS) {
230 "%s %s %s set but not used",
237 if (!is_anon_idf(idf) && fund != ERRONEOUS) {
239 "%s %s %s not used anywhere",
247 register char *fn = def->df_file;
249 if ( (sc == EXTERN || sc == GLOBAL)
250 && def->df_alloc == 0
252 && !def->df_initialized
254 && strcmp(&fn[strlen(fn)-2], ".c") == 0
259 "%s %s %s not used anywhere",
269 change_state(idf, to_state)
271 int to_state; /* SET or USED */
273 /* Changes the state of the variable identified by idf in the current state
274 * on top of the stack.
275 * The fields in the def-descriptor are set too.
277 register struct def *def = idf->id_def;
278 register struct auto_def *a = top_ls->ls_current->st_auto_list;
291 /* adjust minimum required brace level */
292 if (def->df_firstbrace == 0) {
293 def->df_firstbrace = brace_count;
294 def->df_minlevel = level;
297 register struct brace *br = top_br;
299 /* find the smallest brace range from which
300 firstbrace is visible
302 while (br && br->br_count > def->df_firstbrace) {
305 ASSERT(br && def->df_minlevel >= br->br_level);
306 def->df_minlevel = br->br_level;
309 /* search auto_list */
310 while(a && a->ad_idf != idf)
312 if (a == 0) /* identifier not in list, global definition */
322 if (!is_anon_idf(idf)) {
323 warning("variable %s%s uninitialized",
325 (a->ad_maybe_set ? " possibly" : "")
329 a->ad_set = 1; /* one warning */
336 add_auto(idf) /* to current state on top of lint_stack */
339 /* Check if idf's definition is really an auto (or register).
340 * It could be a static or extern too.
341 * Watch out for formal parameters.
343 register struct def *def = idf->id_def;
347 switch (def->df_sc) {
348 register struct auto_def *a;
351 if (def->df_level < L_LOCAL)
352 return; /* a formal */
358 a->ad_used = def->df_used;
359 a->ad_set = def->df_set;
361 a->next = top_ls->ls_current->st_auto_list;
362 top_ls->ls_current->st_auto_list = a;
369 /* Before leaving a block, remove the auto_defs of the automatic
370 * variables on this level and check if they are used
372 register struct auto_def *a = top_ls->ls_current->st_auto_list;
374 ASSERT(!(a && a->ad_def->df_level > level));
375 while (a && a->ad_def->df_level == level) {
376 struct idf *idf = a->ad_idf;
377 struct def *def = idf->id_def;
379 if (!def->df_used && !is_anon_idf(idf)) {
380 if (def->df_set || a->ad_maybe_set) {
382 "%s set but not used in function %s",
383 idf->id_text, func_name);
387 "%s not used anywhere in function %s",
388 idf->id_text, func_name);
393 register struct auto_def *aux = a;
398 top_ls->ls_current->st_auto_list = a;
403 register struct stack_entry *se = local_level->sl_entry;
405 dbg_lint_stack("lint_end_formals");
406 ASSERT(level == L_FORMAL1);
408 register struct def *def = se->se_idf->id_def;
410 if ( (def && !def->df_used)
411 && !(f_ARGSUSED || LINTLIB)
412 && !is_anon_idf(se->se_idf)
414 def_warning(def, "argument %s not used in function %s",
415 se->se_idf->id_text, func_name);
421 PRIVATE struct auto_def *
422 copy_auto_list(from_al, lvl)
423 struct auto_def *from_al;
426 struct auto_def *start = 0;
427 register struct auto_def **hook = &start;
429 /* skip too high levels */
430 while (from_al && from_al->ad_def->df_level > lvl) {
431 from_al = from_al->next;
435 register struct auto_def *a = new_auto_def();
440 from_al = from_al->next;
448 register struct auto_def *a;
451 register struct auto_def *aux = a;
457 PRIVATE struct state *
458 copy_state(from_st, lvl)
459 struct state *from_st;
462 /* Memory for the struct state and the struct auto_defs is allocated
465 register struct state *st = new_state();
467 st->st_auto_list = copy_auto_list(from_st->st_auto_list, lvl);
468 st->st_notreached = from_st->st_notreached;
469 st->st_warned = from_st->st_warned;
477 /* This function also frees the list of auto_defs
479 free_auto_list((*stp)->st_auto_list);
485 remove_settings(st, lvl)
489 /* The states of all variables on this level are set to 'not set' and
490 * 'not maybe set'. (I think you have to read this twice.)
492 register struct auto_def *a = st->st_auto_list;
494 while (a && a->ad_def->df_level == lvl) {
495 a->ad_set = a->ad_maybe_set = 0;
501 /******** M E R G E ********/
503 /* modes for merging */
509 merge_states(st1, st2, lvl, mode)
510 struct state *st1, *st2;
512 int mode; /* NORMAL or CASE_BREAK */
514 /* st2 becomes the result.
515 * st1 is left unchanged.
516 * The resulting state is the state the program gets in if st1 OR st2
517 * becomes the state. (E.g. the states at the end of an if-part and an
518 * end-part are merged by this function.)
520 if (st1->st_notreached) {
521 if (mode == NORMAL || st2->st_notreached) {
523 merge_autos(st1->st_auto_list,
524 st2->st_auto_list, lvl, USE_ONLY);
528 if (st2->st_notreached) {
529 register struct auto_def *tmp = st2->st_auto_list;
531 st2->st_auto_list = copy_auto_list(st1->st_auto_list, lvl);
532 st2->st_notreached = 0;
534 st2->st_auto_list = merge_autos(tmp, st2->st_auto_list,
539 /* both st1 and st2 reached */
541 merge_autos(st1->st_auto_list, st2->st_auto_list,
546 PRIVATE struct auto_def *
547 merge_autos(a1, a2, lvl, mode)
548 struct auto_def *a1, *a2;
552 /* Returns a pointer to the result.
553 * a1 is left unchanged.
554 * a2 is used to create this result.
555 * The fields are set as follows:
556 * a1_set + a2_set -> set
557 * + a?_maybe_set -> maybe set
558 * ELSE -> NOT set && NOT maybe set
559 * * + a?_used -> used
561 * For mode == CASE_BREAK:
562 * First a2 is taken as the result, then
563 * variables NOT set in a2 and set or maybe set in a1 become 'maybe set'
565 * For mode == USE_ONLY:
566 * Start with a2 as the result.
567 * Variables used in a1 become used in a2.
568 * The rest of the result is not changed.
570 register struct auto_def *a;
572 /* skip too local entries */
573 while (a1 && a1->ad_def->df_level > lvl) {
577 /* discard too local entries */
578 while (a2 && a2->ad_def->df_level > lvl) {
579 register struct auto_def *aux = a2;
584 a = a2; /* pointer to the result */
588 /* merge the auto_defs for one idf */
589 ASSERT(a1->ad_idf == a2->ad_idf);
593 if (mode != USE_ONLY) {
595 && (a1->ad_set || a1->ad_maybe_set)
599 && (a2->ad_set || a2->ad_maybe_set)
603 a2->ad_maybe_set = 1;
615 /******** L I N T S T A C K S E A R C H I N G ********/
617 /* The next four find-functions search the lint_stack for an entry.
618 * The letters mean : w: WHILE; d: DO; f: FOR; s: SWITCH; c: CASE.
621 PRIVATE struct lint_stack_entry *
624 register struct lint_stack_entry *lse = top_ls;
627 switch (lse->ls_class) {
633 lse = lse->ls_previous;
638 PRIVATE struct lint_stack_entry *
641 register struct lint_stack_entry *lse = top_ls;
644 switch (lse->ls_class) {
651 lse = lse->ls_previous;
656 PRIVATE struct lint_stack_entry *
659 register struct lint_stack_entry *lse = top_ls;
662 switch (lse->ls_class) {
667 lse = lse->ls_previous;
672 /******** A C T I O N S : I F ********/
676 register struct lint_stack_entry *new = mk_lint_stack_entry(IF);
678 dbg_lint_stack("start_if_part");
680 hwarning("condition in if statement is constant");
683 /* ls_current: the state at the start of the if-part
689 /* ls_current: the state at the end of the if-part
690 ls_previous->ls_current: the state before the if-part
693 dbg_lint_stack("start_else_part");
695 top_ls->ls_current->st_notreached = 1;
696 top_ls->ls_current->st_warned = 0;
699 top_ls->LS_IF = top_ls->ls_current;
700 /* this is the reason why ls_current is a pointer */
702 copy_state(top_ls->ls_previous->ls_current, level);
703 top_ls->ls_level = level;
704 /* ls_current: the state before the if-part and the else-part
705 LS_IF: the state at the end of the if-part
711 /* ls_current: state at the end of the else-part
712 LS_IF: state at the end of the if-part
715 dbg_lint_stack("end_if_else_stmt");
716 merge_states(top_ls->LS_IF, top_ls->ls_current,
717 top_ls->ls_level, NORMAL);
718 Free_state(&top_ls->LS_IF);
719 Free_state(&top_ls->ls_previous->ls_current);
720 top_ls->ls_previous->ls_current = top_ls->ls_current;
727 ls_current: state at the end of the if-part
730 dbg_lint_stack("end_if_stmt");
731 merge_states(top_ls->ls_current, top_ls->ls_previous->ls_current,
732 top_ls->ls_level, NORMAL);
733 Free_state(&top_ls->ls_current);
737 /******** A C T I O N S : L O O P S ********/
739 start_while_stmt(expr)
742 if (is_cp_cst(expr)) {
743 start_loop_stmt(WHILE, 1, expr->VL_VALUE != (arith)0);
746 start_loop_stmt(WHILE, 0, 0);
752 start_loop_stmt(DO, 1, 1);
759 start_loop_stmt(FOR, 1, 1);
762 if (is_cp_cst(expr)) {
763 start_loop_stmt(FOR, 1, expr->VL_VALUE != (arith)0);
766 start_loop_stmt(FOR, 0, 0);
771 start_loop_stmt(looptype, cst, cond)
773 /* If cst, the condition is a constant and its value is cond
775 register struct lint_stack_entry *new = mk_lint_stack_entry(looptype);
777 dbg_lint_stack("start_loop_stmt");
779 /* while (0) | for (;0;) */
780 hwarning("condition in %s statement is always false",
781 symbol2str(looptype));
782 new->ls_current->st_notreached = 1;
785 /* while (1) | for (;;) | do */
786 /* omitting the copy for LS_LOOP will force this loop
787 to be treated as a do loop
789 top_ls->ls_current->st_notreached = 1;
790 top_ls->ls_current->st_warned = 0;
793 new->LS_LOOP = copy_state(top_ls->ls_current, level);
795 new->LS_TEST = (!cst ? TEST_VAR : cond ? TEST_TRUE : TEST_FALSE);
798 /* ls_current: the state at the start of the body
799 LS_TEST: info about the loop test
800 LS_BODY: 0, the state at the end of the body
801 LS_LOOP: the state at the end of the loop, or 0 if the loop
808 register struct lint_stack_entry *lse = find_wdf();
810 dbg_lint_stack("end_loop_body");
811 ASSERT(lse == top_ls);
812 if (!lse->ls_current->st_notreached)
818 register struct lint_stack_entry *lse = find_wdf();
820 dbg_lint_stack("end_loop_stmt");
821 ASSERT(lse == top_ls);
822 if (lse->LS_TEST != TEST_TRUE)
825 dbg_lint_stack("end_loop_stmt after break_merge");
826 if (!top_ls->LS_LOOP) {
827 /* no break met; this is really an endless loop */
828 hwarning("endless %s loop", symbol2str(top_ls->ls_class));
829 Free_state(&top_ls->ls_current);
832 Free_state(&top_ls->ls_current);
833 Free_state(&top_ls->ls_previous->ls_current);
834 top_ls->ls_previous->ls_current = top_ls->LS_LOOP;
839 end_do_stmt(cst, cond)
841 register struct lint_stack_entry *lse = find_wdf();
843 dbg_lint_stack("end_do_stmt");
845 /* do ... while (0) */
846 hwarning("condition in do statement is always false");
848 lse->LS_TEST = (!cst ? TEST_VAR : cond ? TEST_TRUE : TEST_FALSE);
855 register struct lint_stack_entry *lse = find_wdf();
857 dbg_lint_stack("lint_continue_stmt");
859 return; /* not inside a loop statement */
862 top_ls->ls_current->st_notreached = 1;
863 top_ls->ls_current->st_warned = 0;
866 /******** A C T I O N S : S W I T C H ********/
868 start_switch_part(cst)
870 /* ls_current of a SWITCH entry has different meaning from ls_current of
871 * other entries. It keeps track of which variables are used in all
872 * following case parts. (Needed for variables declared in a compound
875 register struct lint_stack_entry *new = mk_lint_stack_entry(SWITCH);
877 dbg_lint_stack("start_switch_part");
879 hwarning("value in switch statement is constant");
881 new->LS_CASE = copy_state(top_ls->ls_current, level);
882 new->ls_current->st_notreached = 1;
883 new->ls_current->st_warned = 0;
884 top_ls->ls_current->st_notreached = 1;
885 top_ls->ls_current->st_warned = 0;
892 dbg_lint_stack("end_switch_stmt");
893 if (top_ls->ls_class == CASE) {
894 /* no break after last case or default */
895 lint_break_stmt(); /* introduce break */
898 if (!top_ls->LS_DEFAULT_MET) {
899 top_ls->ls_current->st_notreached = 0;
900 if (top_ls->LS_BREAK) {
901 merge_states(top_ls->ls_current, top_ls->LS_BREAK,
902 top_ls->ls_level, NORMAL);
903 Free_state(&top_ls->ls_current);
906 top_ls->LS_BREAK = top_ls->ls_current;
910 Free_state(&top_ls->ls_current);
913 if (top_ls->LS_BREAK) {
914 merge_states(top_ls->LS_CASE, top_ls->LS_BREAK,
915 top_ls->ls_level, CASE_BREAK);
916 Free_state(&top_ls->LS_CASE);
919 top_ls->LS_BREAK = top_ls->LS_CASE;
922 top_ls->LS_BREAK->st_notreached =
923 top_ls->ls_previous->ls_current->st_notreached;
925 Free_state(&top_ls->ls_previous->ls_current);
927 if (!top_ls->LS_DEFAULT_MET)
928 top_ls->LS_BREAK->st_notreached = 0;
929 top_ls->ls_previous->ls_current = top_ls->LS_BREAK;
936 /* A default statement is just a special case statement */
937 register struct lint_stack_entry *cs_entry = find_cs();
939 dbg_lint_stack("lint_case_stmt");
941 return; /* not inside switch */
943 if (cs_entry != top_ls) {
944 warning("%s statement in strange context",
945 dflt ? "default" : "case");
949 switch (cs_entry->ls_class) {
950 register struct lint_stack_entry *new;
954 cs_entry->LS_DEFAULT_MET = 1;
957 new = mk_lint_stack_entry(CASE);
958 remove_settings(new->ls_current, level);
963 ASSERT(top_ls->ls_previous->ls_class == SWITCH);
965 cs_entry->ls_previous->LS_DEFAULT_MET = 1;
967 merge_states(top_ls->ls_current, top_ls->ls_previous->LS_CASE,
968 top_ls->ls_previous->ls_level, NORMAL);
969 merge_states(top_ls->ls_current,
970 top_ls->ls_previous->ls_current,
971 top_ls->ls_previous->ls_level, NORMAL);
972 Free_state(&top_ls->ls_current);
974 copy_state(top_ls->ls_previous->ls_current,
975 top_ls->ls_previous->ls_level);
976 remove_settings(top_ls->ls_current, top_ls->ls_level);
987 register struct lint_stack_entry *lse = find_wdfc();
989 dbg_lint_stack("lint_break_stmt");
993 switch (lse->ls_class) {
998 lse->ls_previous->ls_current->st_notreached = 0;
1004 if (!top_ls->ls_current->st_notreached) {
1005 lse->ls_previous->ls_previous->ls_current->st_notreached = 0;
1007 merge_states(lse->ls_current, lse->ls_previous->ls_current,
1008 lse->ls_previous->ls_level, NORMAL);
1009 if (lse->ls_previous->LS_BREAK) {
1010 merge_states(top_ls->ls_current,
1011 lse->ls_previous->LS_BREAK,
1012 lse->ls_previous->ls_level, NORMAL);
1015 lse->ls_previous->LS_BREAK =
1016 copy_state(top_ls->ls_current,
1017 lse->ls_previous->ls_level);
1019 if (lse == top_ls) {
1020 Free_state(&lse->ls_current);
1029 top_ls->ls_current->st_notreached = 1;
1030 top_ls->ls_current->st_warned = 0;
1035 struct lint_stack_entry *lse;
1037 /* merge for continue statements */
1039 merge_states(top_ls->ls_current, lse->LS_BODY,
1040 lse->ls_level, NORMAL);
1043 lse->LS_BODY = copy_state(top_ls->ls_current, lse->ls_level);
1049 struct lint_stack_entry *lse;
1051 /* merge for break statements */
1053 merge_states(top_ls->ls_current, lse->LS_LOOP,
1054 lse->ls_level, NORMAL);
1057 lse->LS_LOOP = copy_state(top_ls->ls_current, lse->ls_level);
1061 /******** A C T I O N S : R E T U R N ********/
1063 lint_start_function()
1066 dbg_lint_stack("lint_start_function");
1067 valreturned = NORETURN; /* initialization */
1069 lint_comment_function();
1075 dbg_lint_stack("lint_end_function");
1076 /* write the function definition record */
1079 /* At this stage it is possible that top_ls->ls_current is
1080 * pointing to a state with a list of auto_defs.
1081 * These auto_defs must be freed and the state must be filled
1084 ASSERT(!top_ls->ls_previous);
1085 free_auto_list(top_ls->ls_current->st_auto_list);
1086 top_ls->ls_current->st_auto_list = 0;
1087 top_ls->ls_current->st_notreached = 0;
1088 top_ls->ls_current->st_warned = 0;
1091 lint_implicit_return()
1094 dbg_lint_stack("lint_implicit_return");
1095 if (!top_ls->ls_current->st_notreached) {
1096 lint_return_stmt(NOVALRETURNED);
1104 dbg_lint_stack("lint_return_stmt");
1105 if (valreturned == NORETURN) {
1106 /* first return met */
1107 register int fund = func_type->tp_fund;
1109 if ( e == NOVALRETURNED
1110 && !func_notypegiven
1112 && fund != ERRONEOUS
1114 warning("function %s declared %s%s but no value returned",
1116 (func_type->tp_unsigned && fund != POINTER) ?
1126 if (valreturned != e && !return_warned) {
1127 warning("function %s does not always return a value",
1132 if (!top_ls->ls_current->st_notreached) {
1133 set_od_valreturned(valreturned);
1135 top_ls->ls_current->st_notreached = 1;
1136 top_ls->ls_current->st_warned = 0;
1139 /******** A C T I O N S : J U M P ********/
1145 dbg_lint_stack("lint_jump_stmt");
1146 top_ls->ls_current->st_notreached = 1;
1147 top_ls->ls_current->st_warned = 0;
1149 idf->id_label->df_used = 1;
1154 /* When meeting a label, we should take the intersection of all
1155 settings at all goto's leading this way, but this cannot reasonably
1156 be done. So we assume that the user knows what he is doing and set
1157 all automatic variables to set.
1159 register struct auto_def *a = top_ls->ls_current->st_auto_list;
1161 dbg_lint_stack("lint_label");
1163 a->ad_maybe_set = 0;
1169 /******** A C T I O N S : S T A T E M E N T ********/
1173 /* Check if this statement can be reached
1176 dbg_lint_stack("lint_statement");
1178 top_ls->ls_current->st_notreached = 1;
1179 top_ls->ls_current->st_warned = 0;
1182 if (DOT == '{' || DOT == ';')
1184 if (top_ls->ls_current->st_warned)
1186 if (top_ls->ls_current->st_notreached) {
1187 if (DOT != CASE && DOT != DEFAULT && AHEAD != ':') {
1188 if (DOT != BREAK || loptions['b'])
1189 warning("statement cannot be reached");
1190 top_ls->ls_current->st_warned = 1;
1193 top_ls->ls_current->st_notreached = 0;
1194 top_ls->ls_current->st_warned = 0;
1199 PRIVATE struct lint_stack_entry *
1200 mk_lint_stack_entry(cl)
1203 /* Prepare a new stack entry for the lint_stack with class cl.
1204 Copy the top ls_current to this entry and set its level.
1206 register struct lint_stack_entry *new = new_lint_stack_entry();
1209 new->ls_current = copy_state(top_ls->ls_current, level);
1210 new->ls_level = level;
1217 struct lint_stack_entry *lse;
1219 lse->ls_previous = top_ls;
1227 top_ls = top_ls->ls_previous;
1228 free_lint_stack_entry(top_ls->next);
1239 struct idf *idf = a->ad_idf;
1240 struct def *def = idf->id_def;
1242 print("%s", idf->id_text);
1243 print("(lvl=%d)", a->ad_def->df_level);
1244 print("(u%ds%dm%d U%dS%d) ",
1245 a->ad_used, a->ad_set, a->ad_maybe_set,
1246 def->df_used, def->df_set
1253 pr_lint_state(nm, st)
1259 print("notreached == %d ", st->st_notreached);
1260 print_autos(st->st_auto_list);
1268 print_lint_stack(msg)
1271 register struct lint_stack_entry *lse = top_ls;
1273 print("Lint stack: %s(level=%d)\n", msg, level);
1275 print(" |-------------- level %d ------------\n",
1277 pr_lint_state(" |current", lse->ls_current);
1279 print(" |class == %s\n",
1280 lse->ls_class ? symbol2str(lse->ls_class) : "{");
1282 switch (lse->ls_class) {
1284 pr_lint_state(" |LS_BREAK", lse->LS_BREAK);
1285 pr_lint_state(" |LS_CASE", lse->LS_CASE);
1291 print(" |LS_TEST == %s\n",
1292 lse->LS_TEST == TEST_VAR ? "TEST_VAR" :
1293 lse->LS_TEST == TEST_TRUE ? "TEST_TRUE" :
1294 lse->LS_TEST == TEST_FALSE ? "TEST_FALSE" :
1297 pr_lint_state(" |LS_BODY", lse->LS_BODY);
1298 pr_lint_state(" |LS_LOOP", lse->LS_LOOP);
1302 pr_lint_state(" |LS_IF", lse->LS_IF);
1308 lse = lse->ls_previous;
1310 print(" |--------------\n\n");