l_lint.o: LLlex.h
l_lint.o: Lpars.h
l_lint.o: arith.h
+l_lint.o: assert.h
l_lint.o: code.h
+l_lint.o: debug.h
l_lint.o: def.h
l_lint.o: expr.h
l_lint.o: file_info.h
l_ev_ord.o: LLlex.h
l_ev_ord.o: Lpars.h
l_ev_ord.o: arith.h
+l_ev_ord.o: assert.h
l_ev_ord.o: code.h
+l_ev_ord.o: debug.h
l_ev_ord.o: def.h
l_ev_ord.o: expr.h
l_ev_ord.o: file_info.h
l_outdef.o: LLlex.h
l_outdef.o: Lpars.h
l_outdef.o: arith.h
+l_outdef.o: assert.h
+l_outdef.o: debug.h
l_outdef.o: def.h
l_outdef.o: expr.h
l_outdef.o: field.h
#ifdef DEBUG
/* Note: this macro uses parameter substitution inside strings */
-#define ASSERT(exp) (exp || crash("in %s, %u: assertion %s failed", \
+#define ASSERT(exp) (exp || crash("in %s, %u: assertion %s failed", \
__FILE__, __LINE__, "exp"))
+#define NOTREACHED() crash("in %s, %u: unreachable statement reached", \
+ __FILE__, __LINE__)
#else
#define ASSERT(exp)
+#define NOTREACHED()
#endif DEBUG
#include "arith.h"
#include "l_state.h"
-static int NOTREACHED;
-static int VARARGSn = -1;
-static int ARGSUSED;
-int LINTLIB;
-
-int s_NOTREACHED;
-int f_VARARGSn;
-int f_ARGSUSED;
+/* Since the lexical analyser does a one-token look-ahead, pseudo-
+ comments are read too soon. This is remedied by first storing them
+ in static variables and then moving them to the real variables
+ one token later.
+*/
+
+static int notreached;
+static int varargsN = -1;
+static int argsused;
+static check_pseudo();
+
+int LINTLIB; /* file is lint library */
+int s_NOTREACHED; /* statement not reached */
+int f_VARARGSn; /* function with variable # of args */
+int f_ARGSUSED; /* function does not use all args */
set_not_reached()
{
- NOTREACHED = 1;
+ notreached = 1;
}
move_NOT2s()
{
- s_NOTREACHED = NOTREACHED;
- NOTREACHED = 0;
+ s_NOTREACHED = notreached;
+ notreached = 0;
}
set_varargs(n)
{
- VARARGSn = n;
+ varargsN = n;
}
move_VAR2f()
{
- f_VARARGSn = VARARGSn;
- VARARGSn = -1;
+ f_VARARGSn = varargsN;
+ varargsN = -1;
}
set_argsused(n)
{
- ARGSUSED = n;
+ argsused = n;
}
move_ARG2f()
{
- f_ARGSUSED = ARGSUSED;
- ARGSUSED = 0;
+ f_ARGSUSED = argsused;
+ argsused = 0;
}
set_lintlib()
i = 0;
return;
}
+
if (position == IN_COMMENT)
return;
+
if (position == IN_SPACE) {
if (c == ' ' || c == '\t')
return;
#include <ctype.h>
+static
check_pseudo(buf, i)
char *buf;
{
* (the u_nderscores are there to not confuse (UNIX) lint)
*/
buf[i++] = '\0';
- if (!strcmp(buf, "NOTREACHED"))
+ if (strcmp(buf, "NOTREACHED") == 0) {
set_not_reached();
- else if (!strcmp(buf, "ARGSUSED"))
+ }
+ else if (strcmp(buf, "ARGSUSED") == 0) {
set_argsused(1);
- else if (!strcmp(buf, "LINTLIBRARY"))
+ }
+ else if (strcmp(buf, "LINTLIBRARY") == 0) {
set_lintlib();
- else if (!strncmp(buf, "VARARGS", 7)) {
- if (i == 8)
+ }
+ else if (strncmp(buf, "VARARGS", 7) == 0) {
+ if (i == 8) {
set_varargs(0);
- else if (i == 9 && isdigit(buf[7]))
+ }
+ else if (i == 9 && isdigit(buf[7])) {
set_varargs(atoi(&buf[7]));
+ }
}
}
#ifdef LINT
#include <alloc.h> /* for st_free */
+#include "assert.h"
#include "arith.h" /* definition arith */
#include "label.h" /* definition label */
#include "expr.h"
{
register struct expr_state *esp = *espp;
- if (value.vl_class != Name) {
- crash("(add_expr_state) invalid vl_class");
- /*NOTREACHED*/
- }
+ ASSERT(value.vl_class == Name);
while ( esp
&& !( esp->es_idf == value.vl_data.vl_idf
&& esp->es_offset == value.vl_value
#ifdef LINT
#include <alloc.h> /* for st_free */
+#include "assert.h"
#include "arith.h" /* definition arith */
#include "label.h" /* definition label */
#include "expr.h"
}
default:
- crash("(lint_expr) bad value class\n");
+ NOTREACHED();
/* NOTREACHED */
}
}
#include <alloc.h>
#include "arith.h"
+#include "assert.h"
#include "type.h"
#include "LLlex.h"
#include "Lpars.h"
case VU:
break;
default:
- crash("(output_def) illegal class");
+ NOTREACHED();
/*NOTREACHED*/
}
printf(":");
register struct tp_entry *tmp;
while (n--) {
- if (!te) {
- crash("(outtypes) not enough tp_entries");
- /*NOTREACHED*/
- }
+ ASSERT(te);
printf(":");
if (te->te_class == Const && te->te_value >= 0) {
/* constant non-negative actual parameter */
printf("%s", symbol2str(tp->tp_fund));
break;
default:
- crash("(outtype) illegal tp_fund");
+ NOTREACHED();
/*NOTREACHED*/
}
}
register struct auto_def *a1 = top_ls->ls_current->st_auto_list;
register struct auto_def *a2;
- if (a1 && a1->ad_def->df_level > level) {
- crash("(check_autos) corrupt level in st_auto_list");
- /*NOTREACHED*/
- }
+ ASSERT(!(a1 && a1->ad_def->df_level > level));
while (a1 && a1->ad_def->df_level == level) {
a2 = a1;
a1 = a1->next;
register struct stack_entry *se = local_level->sl_entry;
extern int f_ARGSUSED;
- if (level != L_FORMAL1) {
- crash("(check_args_used) invalid level %d", level);
- /*NOTREACHED*/
- }
+ ASSERT(level == L_FORMAL1);
while (se) {
register struct def *def = se->se_idf->id_def;
}
a = a2; /* pointer to the result */
while (a1) {
- if (!a2) {
- crash("(merge_autos) a1 longer than a2");
- /*NOTREACHED*/
- }
- if (a1->ad_idf != a2->ad_idf) {
- crash("(merge_autos) identifiers should be the same %s %s",
- a1->ad_idf->id_text, a2->ad_idf->id_text);
- /*NOTREACHED*/
- }
-
+ ASSERT(a2);
+ ASSERT(a1->ad_idf == a2->ad_idf);
if (a1->ad_used)
a2->ad_used = 1;
a1 = a1->next;
a2 = a2->next;
}
- if (a2) {
- crash("(merge_autos) a2 longer than a1");
- /*NOTREACHED*/
- }
+ ASSERT(!a2);
return a;
}
}
break;
default:
- /* bad break */
- crash("find_wdfc() returned invalid entry");
+ NOTREACHED();
/*NOTREACHED*/
}
top_ls->ls_current->st_notreached = 1;
* These auto_defs must be freed and the state must be filled
* with zeros.
*/
- if (top_ls != &stack_bottom) {
- crash("(lint_end_function) top_ls != &stack_bottom");
- /*NOTREACHED*/
- }
+ ASSERT(top_ls == &stack_bottom);
if (top_ls->ls_current->st_auto_list != 0)
free_st_auto_list(top_ls->ls_current->st_auto_list);
top_ls->ls_current->st_auto_list = 0;