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 3.16 1994/06/24 12:05:00 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;
131 register struct def *def = idf->id_def;
134 lint_1_local(idf, def);
139 /* remove entry from brace stack */
146 lint_1_local(idf, def)
150 register int sc = def->df_sc;
152 if ( (sc == STATIC || sc == LABEL)
156 def_warning(def, "%s %s not applied anywhere in function %s",
157 symbol2str(sc), idf->id_text, func_name);
162 && !def->df_initialized
163 && def->df_firstbrace != 0
164 && def->df_minlevel != level
167 register int diff = def->df_minlevel - level;
170 "local %s could be declared %d level%s deeper",
171 idf->id_text, diff, (diff == 1 ? "" : "s")
177 struct stack_level *stl;
179 register struct stack_entry *se = stl->sl_entry;
181 dbg_lint_stack("lint_end_global");
182 ASSERT(level == L_GLOBAL);
184 register struct idf *idf = se->se_idf;
185 register struct def *def = idf->id_def;
188 lint_1_global(idf, def);
195 lint_1_global(idf, def)
199 register int sc = def->df_sc;
200 register int fund = def->df_type->tp_fund;
208 #endif /* IMPLICIT */
209 if (fund == ERRONEOUS)
212 if (def->df_set || def->df_used) {
213 /* Output a line to the intermediate file for
214 * used external variables (including functions)
219 if (sc == STATIC && !def->df_used) {
221 if (!is_anon_idf(idf) && fund != ERRONEOUS) {
223 "%s %s %s set but not used",
230 if (!is_anon_idf(idf) && fund != ERRONEOUS) {
232 "%s %s %s not used anywhere",
240 register char *fn = def->df_file;
242 if ( (sc == EXTERN || sc == GLOBAL)
243 && def->df_alloc == 0
245 && !def->df_initialized
247 && strcmp(&fn[strlen(fn)-2], ".c") == 0
252 "%s %s %s not used anywhere",
262 change_state(idf, to_state)
264 int to_state; /* SET or USED */
266 /* Changes the state of the variable identified by idf in the current state
267 * on top of the stack.
268 * The fields in the def-descriptor are set too.
270 register struct def *def = idf->id_def;
271 register struct auto_def *a = top_ls->ls_current->st_auto_list;
284 /* adjust minimum required brace level */
285 if (def->df_firstbrace == 0) {
286 def->df_firstbrace = brace_count;
287 def->df_minlevel = level;
290 register struct brace *br = top_br;
292 /* find the smallest brace range from which
293 firstbrace is visible
295 while (br && br->br_count > def->df_firstbrace) {
298 ASSERT(br && def->df_minlevel >= br->br_level);
299 def->df_minlevel = br->br_level;
302 /* search auto_list */
303 while(a && a->ad_idf != idf)
305 if (a == 0) /* identifier not in list, global definition */
315 if (!is_anon_idf(idf)) {
316 warning("variable %s%s uninitialized",
318 (a->ad_maybe_set ? " possibly" : "")
322 a->ad_set = 1; /* one warning */
329 add_auto(idf) /* to current state on top of lint_stack */
332 /* Check if idf's definition is really an auto (or register).
333 * It could be a static or extern too.
334 * Watch out for formal parameters.
336 register struct def *def = idf->id_def;
340 switch (def->df_sc) {
341 register struct auto_def *a;
344 if (def->df_level < L_LOCAL)
345 return; /* a formal */
351 a->ad_used = def->df_used;
352 a->ad_set = def->df_set;
354 a->next = top_ls->ls_current->st_auto_list;
355 top_ls->ls_current->st_auto_list = a;
362 /* Before leaving a block, remove the auto_defs of the automatic
363 * variables on this level and check if they are used
365 register struct auto_def *a = top_ls->ls_current->st_auto_list;
367 ASSERT(!(a && a->ad_def->df_level > level));
368 while (a && a->ad_def->df_level == level) {
369 struct idf *idf = a->ad_idf;
370 struct def *def = idf->id_def;
372 if (!def->df_used && !is_anon_idf(idf)) {
373 if (def->df_set || a->ad_maybe_set) {
375 "%s set but not used in function %s",
376 idf->id_text, func_name);
380 "%s not used anywhere in function %s",
381 idf->id_text, func_name);
386 register struct auto_def *aux = a;
391 top_ls->ls_current->st_auto_list = a;
396 register struct stack_entry *se = local_level->sl_entry;
398 dbg_lint_stack("lint_end_formals");
399 ASSERT(level == L_FORMAL1);
401 register struct def *def = se->se_idf->id_def;
403 if ( (def && !def->df_used)
404 && !(f_ARGSUSED || LINTLIB)
405 && !is_anon_idf(se->se_idf)
407 def_warning(def, "argument %s not used in function %s",
408 se->se_idf->id_text, func_name);
414 PRIVATE struct auto_def *
415 copy_auto_list(from_al, lvl)
416 struct auto_def *from_al;
419 struct auto_def *start = 0;
420 register struct auto_def **hook = &start;
422 /* skip too high levels */
423 while (from_al && from_al->ad_def->df_level > lvl) {
424 from_al = from_al->next;
428 register struct auto_def *a = new_auto_def();
433 from_al = from_al->next;
441 register struct auto_def *a;
444 register struct auto_def *aux = a;
450 PRIVATE struct state *
451 copy_state(from_st, lvl)
452 struct state *from_st;
455 /* Memory for the struct state and the struct auto_defs is allocated
458 register struct state *st = new_state();
460 st->st_auto_list = copy_auto_list(from_st->st_auto_list, lvl);
461 st->st_notreached = from_st->st_notreached;
462 st->st_warned = from_st->st_warned;
470 /* This function also frees the list of auto_defs
472 free_auto_list((*stp)->st_auto_list);
478 remove_settings(st, lvl)
482 /* The states of all variables on this level are set to 'not set' and
483 * 'not maybe set'. (I think you have to read this twice.)
485 register struct auto_def *a = st->st_auto_list;
487 while (a && a->ad_def->df_level == lvl) {
488 a->ad_set = a->ad_maybe_set = 0;
494 /******** M E R G E ********/
496 /* modes for merging */
502 merge_states(st1, st2, lvl, mode)
503 struct state *st1, *st2;
505 int mode; /* NORMAL or CASE_BREAK */
507 /* st2 becomes the result.
508 * st1 is left unchanged.
509 * The resulting state is the state the program gets in if st1 OR st2
510 * becomes the state. (E.g. the states at the end of an if-part and an
511 * end-part are merged by this function.)
513 if (st1->st_notreached) {
514 if (mode == NORMAL || st2->st_notreached) {
516 merge_autos(st1->st_auto_list,
517 st2->st_auto_list, lvl, USE_ONLY);
521 if (st2->st_notreached) {
522 register struct auto_def *tmp = st2->st_auto_list;
524 st2->st_auto_list = copy_auto_list(st1->st_auto_list, lvl);
525 st2->st_notreached = 0;
527 st2->st_auto_list = merge_autos(tmp, st2->st_auto_list,
532 /* both st1 and st2 reached */
534 merge_autos(st1->st_auto_list, st2->st_auto_list,
539 PRIVATE struct auto_def *
540 merge_autos(a1, a2, lvl, mode)
541 struct auto_def *a1, *a2;
545 /* Returns a pointer to the result.
546 * a1 is left unchanged.
547 * a2 is used to create this result.
548 * The fields are set as follows:
549 * a1_set + a2_set -> set
550 * + a?_maybe_set -> maybe set
551 * ELSE -> NOT set && NOT maybe set
552 * * + a?_used -> used
554 * For mode == CASE_BREAK:
555 * First a2 is taken as the result, then
556 * variables NOT set in a2 and set or maybe set in a1 become 'maybe set'
558 * For mode == USE_ONLY:
559 * Start with a2 as the result.
560 * Variables used in a1 become used in a2.
561 * The rest of the result is not changed.
563 register struct auto_def *a;
565 /* skip too local entries */
566 while (a1 && a1->ad_def->df_level > lvl) {
570 /* discard too local entries */
571 while (a2 && a2->ad_def->df_level > lvl) {
572 register struct auto_def *aux = a2;
577 a = a2; /* pointer to the result */
581 /* merge the auto_defs for one idf */
582 ASSERT(a1->ad_idf == a2->ad_idf);
586 if (mode != USE_ONLY) {
588 && (a1->ad_set || a1->ad_maybe_set)
592 && (a2->ad_set || a2->ad_maybe_set)
596 a2->ad_maybe_set = 1;
608 /******** L I N T S T A C K S E A R C H I N G ********/
610 /* The next four find-functions search the lint_stack for an entry.
611 * The letters mean : w: WHILE; d: DO; f: FOR; s: SWITCH; c: CASE.
614 PRIVATE struct lint_stack_entry *
617 register struct lint_stack_entry *lse = top_ls;
620 switch (lse->ls_class) {
626 lse = lse->ls_previous;
631 PRIVATE struct lint_stack_entry *
634 register struct lint_stack_entry *lse = top_ls;
637 switch (lse->ls_class) {
644 lse = lse->ls_previous;
649 PRIVATE struct lint_stack_entry *
652 register struct lint_stack_entry *lse = top_ls;
655 switch (lse->ls_class) {
660 lse = lse->ls_previous;
665 /******** A C T I O N S : I F ********/
669 register struct lint_stack_entry *new = mk_lint_stack_entry(IF);
671 dbg_lint_stack("start_if_part");
673 hwarning("condition in if statement is constant");
676 /* ls_current: the state at the start of the if-part
682 /* ls_current: the state at the end of the if-part
683 ls_previous->ls_current: the state before the if-part
686 dbg_lint_stack("start_else_part");
688 top_ls->ls_current->st_notreached = 1;
689 top_ls->ls_current->st_warned = 0;
692 top_ls->LS_IF = top_ls->ls_current;
693 /* this is the reason why ls_current is a pointer */
695 copy_state(top_ls->ls_previous->ls_current, level);
696 top_ls->ls_level = level;
697 /* ls_current: the state before the if-part and the else-part
698 LS_IF: the state at the end of the if-part
704 /* ls_current: state at the end of the else-part
705 LS_IF: state at the end of the if-part
708 dbg_lint_stack("end_if_else_stmt");
709 merge_states(top_ls->LS_IF, top_ls->ls_current,
710 top_ls->ls_level, NORMAL);
711 Free_state(&top_ls->LS_IF);
712 Free_state(&top_ls->ls_previous->ls_current);
713 top_ls->ls_previous->ls_current = top_ls->ls_current;
720 ls_current: state at the end of the if-part
723 dbg_lint_stack("end_if_stmt");
724 merge_states(top_ls->ls_current, top_ls->ls_previous->ls_current,
725 top_ls->ls_level, NORMAL);
726 Free_state(&top_ls->ls_current);
730 /******** A C T I O N S : L O O P S ********/
732 start_while_stmt(expr)
735 if (is_cp_cst(expr)) {
736 start_loop_stmt(WHILE, 1, expr->VL_VALUE != (arith)0);
739 start_loop_stmt(WHILE, 0, 0);
745 start_loop_stmt(DO, 1, 1);
752 start_loop_stmt(FOR, 1, 1);
755 if (is_cp_cst(expr)) {
756 start_loop_stmt(FOR, 1, expr->VL_VALUE != (arith)0);
759 start_loop_stmt(FOR, 0, 0);
764 start_loop_stmt(looptype, cst, cond)
766 /* If cst, the condition is a constant and its value is cond
768 register struct lint_stack_entry *new = mk_lint_stack_entry(looptype);
770 dbg_lint_stack("start_loop_stmt");
772 /* while (0) | for (;0;) */
773 hwarning("condition in %s statement is always false",
774 symbol2str(looptype));
775 new->ls_current->st_notreached = 1;
778 /* while (1) | for (;;) | do */
779 /* omitting the copy for LS_LOOP will force this loop
780 to be treated as a do loop
782 top_ls->ls_current->st_notreached = 1;
783 top_ls->ls_current->st_warned = 0;
786 new->LS_LOOP = copy_state(top_ls->ls_current, level);
788 new->LS_TEST = (!cst ? TEST_VAR : cond ? TEST_TRUE : TEST_FALSE);
791 /* ls_current: the state at the start of the body
792 LS_TEST: info about the loop test
793 LS_BODY: 0, the state at the end of the body
794 LS_LOOP: the state at the end of the loop, or 0 if the loop
801 register struct lint_stack_entry *lse = find_wdf();
803 dbg_lint_stack("end_loop_body");
804 ASSERT(lse == top_ls);
805 if (!lse->ls_current->st_notreached)
811 register struct lint_stack_entry *lse = find_wdf();
813 dbg_lint_stack("end_loop_stmt");
814 ASSERT(lse == top_ls);
815 if (lse->LS_TEST != TEST_TRUE)
818 dbg_lint_stack("end_loop_stmt after break_merge");
819 if (!top_ls->LS_LOOP) {
820 /* no break met; this is really an endless loop */
821 hwarning("endless %s loop", symbol2str(top_ls->ls_class));
822 Free_state(&top_ls->ls_current);
825 Free_state(&top_ls->ls_current);
826 Free_state(&top_ls->ls_previous->ls_current);
827 top_ls->ls_previous->ls_current = top_ls->LS_LOOP;
832 end_do_stmt(cst, cond)
834 register struct lint_stack_entry *lse = find_wdf();
836 dbg_lint_stack("end_do_stmt");
838 /* do ... while (0) */
839 hwarning("condition in do statement is always false");
841 lse->LS_TEST = (!cst ? TEST_VAR : cond ? TEST_TRUE : TEST_FALSE);
848 register struct lint_stack_entry *lse = find_wdf();
850 dbg_lint_stack("lint_continue_stmt");
852 return; /* not inside a loop statement */
855 top_ls->ls_current->st_notreached = 1;
856 top_ls->ls_current->st_warned = 0;
859 /******** A C T I O N S : S W I T C H ********/
861 start_switch_part(cst)
863 /* ls_current of a SWITCH entry has different meaning from ls_current of
864 * other entries. It keeps track of which variables are used in all
865 * following case parts. (Needed for variables declared in a compound
868 register struct lint_stack_entry *new = mk_lint_stack_entry(SWITCH);
870 dbg_lint_stack("start_switch_part");
872 hwarning("value in switch statement is constant");
874 new->LS_CASE = copy_state(top_ls->ls_current, level);
875 new->ls_current->st_notreached = 1;
876 new->ls_current->st_warned = 0;
877 top_ls->ls_current->st_notreached = 1;
878 top_ls->ls_current->st_warned = 0;
885 dbg_lint_stack("end_switch_stmt");
886 if (top_ls->ls_class == CASE) {
887 /* no break after last case or default */
888 lint_break_stmt(); /* introduce break */
891 if (!top_ls->LS_DEFAULT_MET) {
892 top_ls->ls_current->st_notreached = 0;
893 if (top_ls->LS_BREAK) {
894 merge_states(top_ls->ls_current, top_ls->LS_BREAK,
895 top_ls->ls_level, NORMAL);
896 Free_state(&top_ls->ls_current);
899 top_ls->LS_BREAK = top_ls->ls_current;
903 Free_state(&top_ls->ls_current);
906 if (top_ls->LS_BREAK) {
907 merge_states(top_ls->LS_CASE, top_ls->LS_BREAK,
908 top_ls->ls_level, CASE_BREAK);
909 Free_state(&top_ls->LS_CASE);
912 top_ls->LS_BREAK = top_ls->LS_CASE;
915 top_ls->LS_BREAK->st_notreached =
916 top_ls->ls_previous->ls_current->st_notreached;
918 Free_state(&top_ls->ls_previous->ls_current);
920 if (!top_ls->LS_DEFAULT_MET)
921 top_ls->LS_BREAK->st_notreached = 0;
922 top_ls->ls_previous->ls_current = top_ls->LS_BREAK;
929 /* A default statement is just a special case statement */
930 register struct lint_stack_entry *cs_entry = find_cs();
932 dbg_lint_stack("lint_case_stmt");
934 return; /* not inside switch */
936 if (cs_entry != top_ls) {
937 warning("%s statement in strange context",
938 dflt ? "default" : "case");
942 switch (cs_entry->ls_class) {
943 register struct lint_stack_entry *new;
947 cs_entry->LS_DEFAULT_MET = 1;
950 new = mk_lint_stack_entry(CASE);
951 remove_settings(new->ls_current, level);
956 ASSERT(top_ls->ls_previous->ls_class == SWITCH);
958 cs_entry->ls_previous->LS_DEFAULT_MET = 1;
960 merge_states(top_ls->ls_current, top_ls->ls_previous->LS_CASE,
961 top_ls->ls_previous->ls_level, NORMAL);
962 merge_states(top_ls->ls_current,
963 top_ls->ls_previous->ls_current,
964 top_ls->ls_previous->ls_level, NORMAL);
965 Free_state(&top_ls->ls_current);
967 copy_state(top_ls->ls_previous->ls_current,
968 top_ls->ls_previous->ls_level);
969 remove_settings(top_ls->ls_current, top_ls->ls_level);
980 register struct lint_stack_entry *lse = find_wdfc();
982 dbg_lint_stack("lint_break_stmt");
986 switch (lse->ls_class) {
991 lse->ls_previous->ls_current->st_notreached = 0;
997 if (!top_ls->ls_current->st_notreached) {
998 lse->ls_previous->ls_previous->ls_current->st_notreached = 0;
1000 merge_states(lse->ls_current, lse->ls_previous->ls_current,
1001 lse->ls_previous->ls_level, NORMAL);
1002 if (lse->ls_previous->LS_BREAK) {
1003 merge_states(top_ls->ls_current,
1004 lse->ls_previous->LS_BREAK,
1005 lse->ls_previous->ls_level, NORMAL);
1008 lse->ls_previous->LS_BREAK =
1009 copy_state(top_ls->ls_current,
1010 lse->ls_previous->ls_level);
1012 if (lse == top_ls) {
1013 Free_state(&lse->ls_current);
1022 top_ls->ls_current->st_notreached = 1;
1023 top_ls->ls_current->st_warned = 0;
1028 struct lint_stack_entry *lse;
1030 /* merge for continue statements */
1032 merge_states(top_ls->ls_current, lse->LS_BODY,
1033 lse->ls_level, NORMAL);
1036 lse->LS_BODY = copy_state(top_ls->ls_current, lse->ls_level);
1042 struct lint_stack_entry *lse;
1044 /* merge for break statements */
1046 merge_states(top_ls->ls_current, lse->LS_LOOP,
1047 lse->ls_level, NORMAL);
1050 lse->LS_LOOP = copy_state(top_ls->ls_current, lse->ls_level);
1054 /******** A C T I O N S : R E T U R N ********/
1056 lint_start_function()
1059 dbg_lint_stack("lint_start_function");
1060 valreturned = NORETURN; /* initialization */
1062 lint_comment_function();
1068 dbg_lint_stack("lint_end_function");
1069 /* write the function definition record */
1072 /* At this stage it is possible that top_ls->ls_current is
1073 * pointing to a state with a list of auto_defs.
1074 * These auto_defs must be freed and the state must be filled
1077 ASSERT(!top_ls->ls_previous);
1078 free_auto_list(top_ls->ls_current->st_auto_list);
1079 top_ls->ls_current->st_auto_list = 0;
1080 top_ls->ls_current->st_notreached = 0;
1081 top_ls->ls_current->st_warned = 0;
1084 lint_implicit_return()
1087 dbg_lint_stack("lint_implicit_return");
1088 if (!top_ls->ls_current->st_notreached) {
1089 lint_return_stmt(NOVALRETURNED);
1097 dbg_lint_stack("lint_return_stmt");
1098 if (valreturned == NORETURN) {
1099 /* first return met */
1100 register int fund = func_type->tp_fund;
1102 if ( e == NOVALRETURNED
1103 && !func_notypegiven
1105 && fund != ERRONEOUS
1107 warning("function %s declared %s%s but no value returned",
1109 (func_type->tp_unsigned && fund != POINTER) ?
1119 if (valreturned != e && !return_warned) {
1120 warning("function %s does not always return a value",
1125 if (!top_ls->ls_current->st_notreached) {
1126 set_od_valreturned(valreturned);
1128 top_ls->ls_current->st_notreached = 1;
1129 top_ls->ls_current->st_warned = 0;
1132 /******** A C T I O N S : J U M P ********/
1138 dbg_lint_stack("lint_jump_stmt");
1139 top_ls->ls_current->st_notreached = 1;
1140 top_ls->ls_current->st_warned = 0;
1142 idf->id_def->df_used = 1;
1147 /* When meeting a label, we should take the intersection of all
1148 settings at all goto's leading this way, but this cannot reasonably
1149 be done. So we assume that the user knows what he is doing and set
1150 all automatic variables to set.
1152 register struct auto_def *a = top_ls->ls_current->st_auto_list;
1154 dbg_lint_stack("lint_label");
1156 a->ad_maybe_set = 0;
1162 /******** A C T I O N S : S T A T E M E N T ********/
1166 /* Check if this statement can be reached
1169 dbg_lint_stack("lint_statement");
1171 top_ls->ls_current->st_notreached = 1;
1172 top_ls->ls_current->st_warned = 0;
1175 if (DOT == '{' || DOT == ';')
1177 if (top_ls->ls_current->st_warned)
1179 if (top_ls->ls_current->st_notreached) {
1180 if (DOT != CASE && DOT != DEFAULT && AHEAD != ':') {
1181 if (DOT != BREAK || loptions['b'])
1182 warning("statement cannot be reached");
1183 top_ls->ls_current->st_warned = 1;
1186 top_ls->ls_current->st_notreached = 0;
1187 top_ls->ls_current->st_warned = 0;
1192 PRIVATE struct lint_stack_entry *
1193 mk_lint_stack_entry(cl)
1196 /* Prepare a new stack entry for the lint_stack with class cl.
1197 Copy the top ls_current to this entry and set its level.
1199 register struct lint_stack_entry *new = new_lint_stack_entry();
1202 new->ls_current = copy_state(top_ls->ls_current, level);
1203 new->ls_level = level;
1210 struct lint_stack_entry *lse;
1212 lse->ls_previous = top_ls;
1220 top_ls = top_ls->ls_previous;
1221 free_lint_stack_entry(top_ls->next);
1232 struct idf *idf = a->ad_idf;
1233 struct def *def = idf->id_def;
1235 print("%s", idf->id_text);
1236 print("(lvl=%d)", a->ad_def->df_level);
1237 print("(u%ds%dm%d U%dS%d) ",
1238 a->ad_used, a->ad_set, a->ad_maybe_set,
1239 def->df_used, def->df_set
1246 pr_lint_state(nm, st)
1252 print("notreached == %d ", st->st_notreached);
1253 print_autos(st->st_auto_list);
1261 print_lint_stack(msg)
1264 register struct lint_stack_entry *lse = top_ls;
1266 print("Lint stack: %s(level=%d)\n", msg, level);
1268 print(" |-------------- level %d ------------\n",
1270 pr_lint_state(" |current", lse->ls_current);
1272 print(" |class == %s\n",
1273 lse->ls_class ? symbol2str(lse->ls_class) : "{");
1275 switch (lse->ls_class) {
1277 pr_lint_state(" |LS_BREAK", lse->LS_BREAK);
1278 pr_lint_state(" |LS_CASE", lse->LS_CASE);
1284 print(" |LS_TEST == %s\n",
1285 lse->LS_TEST == TEST_VAR ? "TEST_VAR" :
1286 lse->LS_TEST == TEST_TRUE ? "TEST_TRUE" :
1287 lse->LS_TEST == TEST_FALSE ? "TEST_FALSE" :
1290 pr_lint_state(" |LS_BODY", lse->LS_BODY);
1291 pr_lint_state(" |LS_LOOP", lse->LS_LOOP);
1295 pr_lint_state(" |LS_IF", lse->LS_IF);
1301 lse = lse->ls_previous;
1303 print(" |--------------\n\n");