crash() replaced by ASSERT() & NOTREACHED() in lint
This commit is contained in:
		
							parent
							
								
									3d549e7932
								
							
						
					
					
						commit
						acf34e54ec
					
				
					 7 changed files with 62 additions and 62 deletions
				
			
		| 
						 | 
				
			
			@ -790,7 +790,9 @@ dataflow.o: dataflow.h
 | 
			
		|||
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
 | 
			
		||||
| 
						 | 
				
			
			@ -851,7 +853,9 @@ l_misc.o: type.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
 | 
			
		||||
| 
						 | 
				
			
			@ -870,6 +874,8 @@ l_ev_ord.o: type.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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,8 +14,11 @@
 | 
			
		|||
 | 
			
		||||
#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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,46 +12,53 @@
 | 
			
		|||
#include	"arith.h"
 | 
			
		||||
#include	"l_state.h"
 | 
			
		||||
 | 
			
		||||
static int NOTREACHED;
 | 
			
		||||
static int VARARGSn = -1;
 | 
			
		||||
static int ARGSUSED;
 | 
			
		||||
int LINTLIB;
 | 
			
		||||
/*	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.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
int s_NOTREACHED;
 | 
			
		||||
int f_VARARGSn;
 | 
			
		||||
int f_ARGSUSED;
 | 
			
		||||
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()
 | 
			
		||||
| 
						 | 
				
			
			@ -83,8 +90,10 @@ lint_comment(c)
 | 
			
		|||
		i = 0;
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (position == IN_COMMENT)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	if (position == IN_SPACE) {
 | 
			
		||||
		if (c == ' ' || c == '\t')
 | 
			
		||||
			return;
 | 
			
		||||
| 
						 | 
				
			
			@ -104,6 +113,7 @@ lint_comment(c)
 | 
			
		|||
 | 
			
		||||
#include	<ctype.h>
 | 
			
		||||
 | 
			
		||||
static
 | 
			
		||||
check_pseudo(buf, i)
 | 
			
		||||
	char *buf;
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -112,17 +122,22 @@ check_pseudo(buf, i)
 | 
			
		|||
 * (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]));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,6 +10,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"
 | 
			
		||||
| 
						 | 
				
			
			@ -91,10 +92,7 @@ add_expr_state(value, to_state, espp)
 | 
			
		|||
{
 | 
			
		||||
	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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,6 +10,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"
 | 
			
		||||
| 
						 | 
				
			
			@ -136,7 +137,7 @@ lint_value(expr, val)
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	default:
 | 
			
		||||
		crash("(lint_expr) bad value class\n");
 | 
			
		||||
		NOTREACHED();
 | 
			
		||||
		/* NOTREACHED */
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,6 +11,7 @@
 | 
			
		|||
 | 
			
		||||
#include	<alloc.h>
 | 
			
		||||
#include	"arith.h"
 | 
			
		||||
#include	"assert.h"
 | 
			
		||||
#include	"type.h"
 | 
			
		||||
#include	"LLlex.h"
 | 
			
		||||
#include	"Lpars.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -252,7 +253,7 @@ output_def(od)
 | 
			
		|||
	case VU:
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
		crash("(output_def) illegal class");
 | 
			
		||||
		NOTREACHED();
 | 
			
		||||
		/*NOTREACHED*/
 | 
			
		||||
	}
 | 
			
		||||
	printf(":");
 | 
			
		||||
| 
						 | 
				
			
			@ -268,10 +269,7 @@ outtypes(te, n)
 | 
			
		|||
	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 */
 | 
			
		||||
| 
						 | 
				
			
			@ -338,7 +336,7 @@ outtype(tp)
 | 
			
		|||
		printf("%s", symbol2str(tp->tp_fund));
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
		crash("(outtype) illegal tp_fund");
 | 
			
		||||
		NOTREACHED();
 | 
			
		||||
		/*NOTREACHED*/
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -302,10 +302,7 @@ check_autos()
 | 
			
		|||
	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;
 | 
			
		||||
| 
						 | 
				
			
			@ -331,10 +328,7 @@ check_args_used()
 | 
			
		|||
	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;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -463,16 +457,8 @@ merge_autos(a1, a2, lvl, mode)
 | 
			
		|||
	}
 | 
			
		||||
	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;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -493,10 +479,7 @@ merge_autos(a1, a2, lvl, mode)
 | 
			
		|||
		a1 = a1->next;
 | 
			
		||||
		a2 = a2->next;
 | 
			
		||||
	}
 | 
			
		||||
	if (a2) {
 | 
			
		||||
		crash("(merge_autos) a2 longer than a1");
 | 
			
		||||
		/*NOTREACHED*/
 | 
			
		||||
	}
 | 
			
		||||
	ASSERT(!a2);
 | 
			
		||||
	return a;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -873,8 +856,7 @@ lint_break_stmt()
 | 
			
		|||
		}
 | 
			
		||||
		break;
 | 
			
		||||
	default:
 | 
			
		||||
		/* bad break */
 | 
			
		||||
		crash("find_wdfc() returned invalid entry");
 | 
			
		||||
		NOTREACHED();
 | 
			
		||||
		/*NOTREACHED*/
 | 
			
		||||
	}
 | 
			
		||||
	top_ls->ls_current->st_notreached = 1;
 | 
			
		||||
| 
						 | 
				
			
			@ -911,10 +893,7 @@ lint_end_function()
 | 
			
		|||
	 * 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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue