better error reporting

This commit is contained in:
dick 1989-10-04 15:36:56 +00:00
parent 53fe78afae
commit d75369dd40
5 changed files with 35 additions and 13 deletions

View file

@ -6,7 +6,7 @@
# M A K E F I L E F O R L P A S S 2
# Machine and environ dependent definitions
EMHOME = /usr/em
EMHOME = /usr/proj/em/Work
LPASS1 = $(EMHOME)/lang/cem/cemcom
# Libraries and EM interface definitions
@ -28,8 +28,8 @@ SRC = lpass2.c checkargs.c read.c report.c class.c l_print3ack.c
OBJ = lpass2.o checkargs.o read.o report.o class.o l_print3ack.o
test: lpass2
lpass2 -xh <.i
# make lint.test
make lint.test
# lpass2 -xh <.i
lpass2: $(OBJ) Makefile next.o

View file

@ -20,6 +20,7 @@ PRIVATE char formatargs[1000]; /* the definitions */
PRIVATE chk_argtps();
PRIVATE char *next_atype();
PRIVATE int type_match();
PRIVATE form_type();
int
type_equal(act, form)
@ -78,8 +79,14 @@ PRIVATE chk_argtps(id, def, nrargs, act_tp, form_tp)
(*nrargs)++;
if (!type_match(id, act_start, form_start)) {
report("%L: arg %d of %s differs from that in %L",
id, *nrargs, id->id_name, def);
char act_form[100];
char form_form[100];
form_type(act_form, act_start);
form_type(form_form, form_start);
report("%L: arg %d of %s (%s) differs from that in %L (%s)",
id, *nrargs, id->id_name,
act_form, def, form_form);
}
act_tp[-1] = ':';
form_tp[-1] = ':';
@ -246,3 +253,19 @@ PRIVATE conv_format(id, act, form)
*fmt++ = '\0';
}
PRIVATE form_type(buff, tp)
char buff[];
char *tp;
{ /* store a formatted version of tp in buff
*/
if (tp[0] == '"') {
strcpy(buff, "char*");
}
else if (tp[0] == '+') {
sprintf(buff, "[unsigned] %s", &tp[1]);
}
else {
strcpy(buff, tp);
}
}

View file

@ -8,7 +8,7 @@
PATH=/bin:/usr/bin
EMLINT=/usr/dick/lint
EMLINT=/home/top/dick/lint
LPASS1="$EMLINT/lpass1/lnt -Dmc68000" # pass 1 program
LPASS2="$EMLINT/lpass2/lpass2" # pass 2 program

View file

@ -96,7 +96,7 @@ PRIVATE init(argc, argv)
switch (ch) {
case 'u':
/* don't report situations like
"defined/declared but not used"
"not used anywhere"
*/
case 'X': /* ??? prints incoming inpdefs */
default: /* and any other */
@ -145,7 +145,7 @@ PRIVATE ext_def()
{
if (same_obj(0) && is_class(dot, CL_EXT|CL_DEF)) {
if (lib) {
report("%L: %s %s also defined in library %L",
report("%L: %s %s also defined in %L",
dot, funvar(dot), dot->id_name, lib);
}
ext = dot;
@ -335,7 +335,7 @@ PRIVATE stat_def(stnr)
{
if (same_obj(stnr) && is_class(dot, CL_STAT|CL_DEF)) {
if (lib) {
report("%L: %s %s also defined in library %L",
report("%L: %s %s also defined in %L",
dot, funvar(dot), dot->id_name, lib);
}
if (ext) {
@ -372,9 +372,8 @@ PRIVATE chk_def(def)
}
else {
if (!loptions['u']) {
report("%L: %s %s %s but not used",
def, funvar(def), def->id_name,
defdec(def));
report("%L: %s %s not used anywhere",
def, funvar(def), def->id_name);
}
}
}

View file

@ -98,7 +98,7 @@ rep_loc(id)
}
else
if (is_class(id, CL_LIB)) {
fprint(MSGOUT, "library file %s", id->id_file);
fprint(MSGOUT, "library");
}
else {
fprint(MSGOUT, "\"%s\", line %d",