more lint code
This commit is contained in:
parent
bb7b8d6490
commit
1d0b3910b2
10 changed files with 578 additions and 412 deletions
|
@ -929,7 +929,6 @@ declar.o: field.h
|
|||
declar.o: file_info.h
|
||||
declar.o: idf.h
|
||||
declar.o: l_lint.h
|
||||
declar.o: l_state.h
|
||||
declar.o: label.h
|
||||
declar.o: level.h
|
||||
declar.o: lint.h
|
||||
|
@ -953,7 +952,6 @@ statement.o: expr.h
|
|||
statement.o: file_info.h
|
||||
statement.o: idf.h
|
||||
statement.o: l_lint.h
|
||||
statement.o: l_state.h
|
||||
statement.o: label.h
|
||||
statement.o: lint.h
|
||||
statement.o: nobitfield.h
|
||||
|
@ -986,7 +984,7 @@ program.o: def.h
|
|||
program.o: expr.h
|
||||
program.o: file_info.h
|
||||
program.o: idf.h
|
||||
program.o: l_state.h
|
||||
program.o: l_lint.h
|
||||
program.o: label.h
|
||||
program.o: lint.h
|
||||
program.o: nobitfield.h
|
||||
|
|
|
@ -280,10 +280,15 @@ ch7bin(expp, oper, expr)
|
|||
break;
|
||||
|
||||
case ',':
|
||||
if (is_cp_cst(*expp))
|
||||
if (is_cp_cst(*expp)) {
|
||||
#ifdef LINT
|
||||
hwarning("constant expression ignored");
|
||||
#endif LINT
|
||||
*expp = expr;
|
||||
else
|
||||
}
|
||||
else {
|
||||
*expp = new_oper(expr->ex_type, *expp, oper, expr);
|
||||
}
|
||||
(*expp)->ex_flags |= EX_COMMA;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "level.h"
|
||||
#ifdef LINT
|
||||
#include "l_lint.h"
|
||||
#include "l_state.h"
|
||||
#endif LINT
|
||||
|
||||
extern char options[];
|
||||
|
|
|
@ -353,7 +353,7 @@ declare_idf(ds, dc, lvl)
|
|||
newdef->df_file = idf->id_file;
|
||||
newdef->df_line = idf->id_line;
|
||||
#ifdef LINT
|
||||
newdef->df_set = (type->tp_fund == ARRAY);
|
||||
newdef->df_set = 0;
|
||||
newdef->df_firstbrace = 0;
|
||||
#endif LINT
|
||||
|
||||
|
@ -490,11 +490,17 @@ global_redecl(idf, new_sc, tp)
|
|||
error("cannot redeclare %s to static",
|
||||
idf->id_text);
|
||||
else {
|
||||
#ifdef LINT /* warn unconditionally */
|
||||
warning("%s redeclared to static",
|
||||
idf->id_text);
|
||||
#else LINT
|
||||
#ifndef NOROPTION
|
||||
/* warn conditionally */
|
||||
if (options['R'])
|
||||
warning("%s redeclared to static",
|
||||
idf->id_text);
|
||||
#endif
|
||||
#endif NOROPTION
|
||||
#endif LINT
|
||||
def->df_sc = STATIC;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -255,14 +255,6 @@ oper2state(expr, val, used)
|
|||
case GREATEREQ:
|
||||
case EQUAL:
|
||||
case NOTEQUAL:
|
||||
lint_relop(left, right, oper);
|
||||
lint_relop(right, left,
|
||||
oper == '<' ? '>' :
|
||||
oper == '>' ? '<' :
|
||||
oper == LESSEQ ? GREATEREQ :
|
||||
oper == GREATEREQ ? LESSEQ :
|
||||
oper
|
||||
);
|
||||
goto dyadic;
|
||||
|
||||
/* dyadic operators */
|
||||
|
@ -338,11 +330,16 @@ expr_ignored(expr)
|
|||
break;
|
||||
|
||||
case Value:
|
||||
hwarning("value as statement");
|
||||
if (expr->VL_CLASS == Const) {
|
||||
hwarning("constant expression ignored");
|
||||
}
|
||||
else {
|
||||
hwarning("value ignored");
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* String Float */
|
||||
hwarning("constant as statement");
|
||||
hwarning("constant ignored");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,35 +12,52 @@
|
|||
* control of the program.
|
||||
*/
|
||||
|
||||
#define TEST_VAR 0 /* not a constant */
|
||||
#define TEST_TRUE 1 /* always true */
|
||||
#define TEST_FALSE 2 /* always false */
|
||||
|
||||
struct switch_states {
|
||||
struct loop_state { /* used in lint_end_state only */
|
||||
int lps_test; /* is the test a constant? */
|
||||
struct state *lps_body;
|
||||
struct state *lps_loop;
|
||||
};
|
||||
|
||||
struct switch_state { /* used in lint_end_state only */
|
||||
struct state *sws_case;
|
||||
struct state *sws_break;
|
||||
int sws_default_met;
|
||||
};
|
||||
|
||||
/* This union describes the (possibly incomplete) state at the end of the
|
||||
mentioned construct.
|
||||
*/
|
||||
union lint_end_state { /* used in lint_stack_entry only */
|
||||
struct state *ule_if;
|
||||
struct loop_state ule_loop;
|
||||
struct switch_state ule_switch;
|
||||
};
|
||||
|
||||
struct lint_stack_entry {
|
||||
struct lint_stack_entry *next;
|
||||
struct lint_stack_entry *ls_previous;
|
||||
short ls_class; /* IF, WHILE, DO, FOR, SWITCH, CASE */
|
||||
int ls_level;
|
||||
struct state *ls_current; /* used by all classes */
|
||||
union {
|
||||
struct state *u_if_state; /* used for IF-class */
|
||||
struct state *u_end; /* used for loop-classes */
|
||||
struct switch_states u_switch;
|
||||
} ls_states; /* not used for CASE-class */
|
||||
short ls_class; /* IF, WHILE, DO, FOR, SWITCH, CASE */
|
||||
union lint_end_state ls_end;
|
||||
};
|
||||
|
||||
/* macros to access the union */
|
||||
#define LS_IF_STATE ls_states.u_if_state
|
||||
#define LS_END ls_states.u_end
|
||||
#define LS_CASE ls_states.u_switch.sws_case
|
||||
#define LS_BREAK ls_states.u_switch.sws_break
|
||||
#define LS_DEFAULT_MET ls_states.u_switch.sws_default_met
|
||||
|
||||
/* ALLOCDEF "lint_stack_entry" 10 */
|
||||
|
||||
/* macros to access the union */
|
||||
#define LS_IF ls_end.ule_if
|
||||
#define LS_TEST ls_end.ule_loop.lps_test
|
||||
#define LS_BODY ls_end.ule_loop.lps_body
|
||||
#define LS_LOOP ls_end.ule_loop.lps_loop
|
||||
#define LS_CASE ls_end.ule_switch.sws_case
|
||||
#define LS_BREAK ls_end.ule_switch.sws_break
|
||||
#define LS_DEFAULT_MET ls_end.ule_switch.sws_default_met
|
||||
|
||||
/* describes a branch in the program, with its local idfs */
|
||||
struct state {
|
||||
struct state *next; /* only used by memory allocator */
|
||||
struct auto_def *st_auto_list;
|
||||
|
@ -50,6 +67,7 @@ struct state {
|
|||
|
||||
/* ALLOCDEF "state" 15 */
|
||||
|
||||
/* describes the state of a local idf in a given branch of the program */
|
||||
struct auto_def {
|
||||
struct auto_def *next;
|
||||
struct idf *ad_idf;
|
||||
|
@ -61,13 +79,14 @@ struct auto_def {
|
|||
|
||||
/* ALLOCDEF "auto_def" 20 */
|
||||
|
||||
struct expr_state {
|
||||
/* describes the state of an idf during expression evaluation */
|
||||
struct expr_state { /*actually concerns idfs only */
|
||||
struct expr_state *next;
|
||||
struct idf *es_idf;
|
||||
struct idf *es_idf; /* the idf with its offset */
|
||||
arith es_offset;
|
||||
int es_used;
|
||||
int es_referred;
|
||||
int es_set;
|
||||
int es_used; /* value has been used */
|
||||
int es_referred; /* address has been taken */
|
||||
int es_set; /* has been assigned to */
|
||||
};
|
||||
|
||||
/* ALLOCDEF "expr_state" 20 */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -58,7 +58,7 @@
|
|||
#include "expr.h"
|
||||
#include "def.h"
|
||||
#ifdef LINT
|
||||
#include "l_state.h"
|
||||
#include "l_lint.h"
|
||||
#endif LINT
|
||||
|
||||
#ifndef NOPP
|
||||
|
@ -205,11 +205,11 @@ function(struct decspecs *ds; struct declarator *dc;)
|
|||
{
|
||||
end_proc(fbytes);
|
||||
#ifdef LINT
|
||||
lint_return_stmt(0); /* implicit return at end of function */
|
||||
lint_implicit_return();
|
||||
#endif LINT
|
||||
unstack_level(); /* L_FORMAL2 declarations */
|
||||
#ifdef LINT
|
||||
check_args_used();
|
||||
lint_end_formals();
|
||||
#endif LINT
|
||||
unstack_level(); /* L_FORMAL1 declarations */
|
||||
#ifdef LINT
|
||||
|
|
|
@ -101,7 +101,7 @@ unstack_level()
|
|||
#endif DEBUG
|
||||
|
||||
#ifdef LINT
|
||||
lint_local_level(local_level);
|
||||
lint_end_local(local_level);
|
||||
#endif LINT
|
||||
|
||||
/* The implementation below is more careful than strictly
|
||||
|
@ -177,7 +177,7 @@ unstack_world()
|
|||
register struct stack_entry *se = local_level->sl_entry;
|
||||
|
||||
#ifdef LINT
|
||||
lint_global_level(local_level);
|
||||
lint_end_global(local_level);
|
||||
#endif LINT
|
||||
|
||||
open_name_list();
|
||||
|
|
|
@ -23,13 +23,12 @@
|
|||
#include "def.h"
|
||||
#ifdef LINT
|
||||
#include "l_lint.h"
|
||||
#include "l_state.h"
|
||||
#endif LINT
|
||||
|
||||
extern int level;
|
||||
}
|
||||
|
||||
/* Each statement construction is stacked in order to trace a
|
||||
/* Each statement construction is stacked in order to trace a ???
|
||||
statement to such a construction. Example: a case statement should
|
||||
be recognized as a piece of the most enclosing switch statement.
|
||||
*/
|
||||
|
@ -209,18 +208,16 @@ while_statement
|
|||
if (expr->VL_VALUE == (arith)0) {
|
||||
C_bra(l_break);
|
||||
}
|
||||
#ifdef LINT
|
||||
start_loop_stmt(WHILE, 1,
|
||||
expr->VL_VALUE != (arith)0);
|
||||
#endif LINT
|
||||
}
|
||||
else {
|
||||
code_expr(expr, RVAL, TRUE, l_body, l_break);
|
||||
C_df_ilb(l_body);
|
||||
#ifdef LINT
|
||||
start_loop_stmt(WHILE, 0, 0);
|
||||
#endif LINT
|
||||
}
|
||||
|
||||
#ifdef LINT
|
||||
start_while_stmt(expr);
|
||||
#endif LINT
|
||||
|
||||
}
|
||||
')'
|
||||
statement
|
||||
|
@ -230,6 +227,7 @@ while_statement
|
|||
unstack_stmt();
|
||||
free_expression(expr);
|
||||
#ifdef LINT
|
||||
end_loop_body();
|
||||
end_loop_stmt();
|
||||
#endif LINT
|
||||
}
|
||||
|
@ -246,13 +244,17 @@ do_statement
|
|||
{ C_df_ilb(l_body);
|
||||
stack_stmt(l_break, l_continue);
|
||||
#ifdef LINT
|
||||
start_loop_stmt(DO, 1, 1);
|
||||
start_do_stmt();
|
||||
#endif LINT
|
||||
}
|
||||
statement
|
||||
WHILE
|
||||
'('
|
||||
{ C_df_ilb(l_continue);
|
||||
{
|
||||
#ifdef LINT
|
||||
end_loop_body();
|
||||
#endif LINT
|
||||
C_df_ilb(l_continue);
|
||||
}
|
||||
expression(&expr)
|
||||
{
|
||||
|
@ -287,9 +289,6 @@ for_statement
|
|||
label l_continue = text_label();
|
||||
label l_body = text_label();
|
||||
label l_test = text_label();
|
||||
#ifdef LINT
|
||||
int const = 1, cond = 1; /* the default case */
|
||||
#endif LINT
|
||||
}
|
||||
:
|
||||
FOR
|
||||
|
@ -312,17 +311,10 @@ for_statement
|
|||
if (e_test->VL_VALUE == (arith)0) {
|
||||
C_bra(l_break);
|
||||
}
|
||||
#ifdef LINT
|
||||
const = 1,
|
||||
cond = e_test->VL_VALUE != (arith)0;
|
||||
#endif LINT
|
||||
}
|
||||
else {
|
||||
code_expr(e_test, RVAL, TRUE, l_body, l_break);
|
||||
C_df_ilb(l_body);
|
||||
#ifdef LINT
|
||||
const = 0, cond = 0;
|
||||
#endif LINT
|
||||
}
|
||||
}
|
||||
]?
|
||||
|
@ -331,13 +323,13 @@ for_statement
|
|||
')'
|
||||
{
|
||||
#ifdef LINT
|
||||
start_loop_stmt(FOR, const, cond);
|
||||
start_for_stmt(e_test);
|
||||
#endif LINT
|
||||
}
|
||||
statement
|
||||
{
|
||||
#ifdef LINT
|
||||
end_loop_stmt();
|
||||
end_loop_body();
|
||||
#endif LINT
|
||||
C_df_ilb(l_continue);
|
||||
if (e_incr)
|
||||
|
@ -349,6 +341,9 @@ for_statement
|
|||
free_expression(e_init);
|
||||
free_expression(e_test);
|
||||
free_expression(e_incr);
|
||||
#ifdef LINT
|
||||
end_loop_stmt();
|
||||
#endif LINT
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -423,7 +418,7 @@ return_statement
|
|||
do_return_expr(expr);
|
||||
free_expression(expr);
|
||||
#ifdef LINT
|
||||
lint_return_stmt(1);
|
||||
lint_return_stmt(VALRETURNED);
|
||||
#endif LINT
|
||||
}
|
||||
|
|
||||
|
@ -431,7 +426,7 @@ return_statement
|
|||
{
|
||||
do_return();
|
||||
#ifdef LINT
|
||||
lint_return_stmt(0);
|
||||
lint_return_stmt(NOVALRETURNED);
|
||||
#endif LINT
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue