Fixed warnings, recognize -gdb

This commit is contained in:
ceriel 1995-12-04 15:29:42 +00:00
parent a9df108116
commit d4abf57904
3 changed files with 59 additions and 26 deletions

View file

@ -72,7 +72,7 @@ debug(char *fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
{ {
_error(VDEBUG, NULLNODE, ap); _error(VDEBUG, NULLNODE, ap, 0);
} }
va_end(ap); va_end(ap);
} }
@ -85,7 +85,7 @@ error(char *fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
{ {
_error(ERROR, NULLNODE, fmt, ap); _error(ERROR, NULLNODE, fmt, ap, 0);
} }
va_end(ap); va_end(ap);
} }
@ -97,31 +97,31 @@ node_error(t_node *node, char *fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
{ {
_error(ERROR, node, fmt, ap); _error(ERROR, node, fmt, ap, 0);
} }
va_end(ap); va_end(ap);
} }
/*VARARGS*/ /*VARARGS*/
warning(char *fmt, ...) warning(int class, char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
{ {
_error(WARNING, NULLNODE, fmt, ap); _error(WARNING, NULLNODE, fmt, ap, class);
} }
va_end(ap); va_end(ap);
} }
/*VARARGS*/ /*VARARGS*/
node_warning(t_node *node, char *fmt, ...) node_warning(t_node *node, int class, char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
{ {
_error(WARNING, node, fmt, ap); _error(WARNING, node, fmt, ap, class);
} }
va_end(ap); va_end(ap);
} }
@ -133,19 +133,19 @@ lexerror(char *fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
{ {
_error(LEXERROR, NULLNODE, fmt, ap); _error(LEXERROR, NULLNODE, fmt, ap, 0);
} }
va_end(ap); va_end(ap);
} }
/*VARARGS*/ /*VARARGS*/
lexwarning(char *fmt, ...) lexwarning(int class, char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
{ {
_error(LEXWARNING, NULLNODE, fmt, ap); _error(LEXWARNING, NULLNODE, fmt, ap, class);
} }
va_end(ap); va_end(ap);
} }
@ -157,7 +157,7 @@ fatal(char *fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
{ {
_error(FATAL, NULLNODE, fmt, ap); _error(FATAL, NULLNODE, fmt, ap, 0);
} }
va_end(ap); va_end(ap);
sys_stop(S_EXIT); sys_stop(S_EXIT);
@ -170,7 +170,7 @@ crash(char *fmt, ...)
va_start(ap, fmt); va_start(ap, fmt);
{ {
_error(CRASH, NULLNODE, fmt, ap); _error(CRASH, NULLNODE, fmt, ap, 0);
} }
va_end(ap); va_end(ap);
#ifdef DEBUG #ifdef DEBUG
@ -190,7 +190,7 @@ debug(va_alist)
va_start(ap); va_start(ap);
{ {
char *fmt = va_arg(ap, char *); char *fmt = va_arg(ap, char *);
_error(VDEBUG, NULLNODE, fmt, ap); _error(VDEBUG, NULLNODE, fmt, ap, 0);
} }
va_end(ap); va_end(ap);
} }
@ -205,7 +205,7 @@ error(va_alist)
va_start(ap); va_start(ap);
{ {
char *fmt = va_arg(ap, char *); char *fmt = va_arg(ap, char *);
_error(ERROR, NULLNODE, fmt, ap); _error(ERROR, NULLNODE, fmt, ap, 0);
} }
va_end(ap); va_end(ap);
} }
@ -220,7 +220,7 @@ node_error(va_alist)
{ {
t_node *node = va_arg(ap, t_node *); t_node *node = va_arg(ap, t_node *);
char *fmt = va_arg(ap, char *); char *fmt = va_arg(ap, char *);
_error(ERROR, node, fmt, ap); _error(ERROR, node, fmt, ap, 0);
} }
va_end(ap); va_end(ap);
} }
@ -233,8 +233,9 @@ warning(va_alist)
va_start(ap); va_start(ap);
{ {
int class = va_arg(ap, int);
char *fmt = va_arg(ap, char *); char *fmt = va_arg(ap, char *);
_error(WARNING, NULLNODE, fmt, ap); _error(WARNING, NULLNODE, fmt, ap, class);
} }
va_end(ap); va_end(ap);
} }
@ -248,8 +249,9 @@ node_warning(va_alist)
va_start(ap); va_start(ap);
{ {
t_node *nd = va_arg(ap, t_node *); t_node *nd = va_arg(ap, t_node *);
int class = va_arg(ap, int);
char *fmt = va_arg(ap, char *); char *fmt = va_arg(ap, char *);
_error(WARNING, nd, fmt, ap); _error(WARNING, nd, fmt, ap, class);
} }
va_end(ap); va_end(ap);
} }
@ -263,7 +265,7 @@ lexerror(va_alist)
va_start(ap); va_start(ap);
{ {
char *fmt = va_arg(ap, char *); char *fmt = va_arg(ap, char *);
_error(LEXERROR, NULLNODE, fmt, ap); _error(LEXERROR, NULLNODE, fmt, ap, 0);
} }
va_end(ap); va_end(ap);
} }
@ -276,8 +278,9 @@ lexwarning(va_alist)
va_start(ap); va_start(ap);
{ {
int class = va_arg(ap, int);
char *fmt = va_arg(ap, char *); char *fmt = va_arg(ap, char *);
_error(LEXWARNING, NULLNODE, fmt, ap); _error(LEXWARNING, NULLNODE, fmt, ap, class);
} }
va_end(ap); va_end(ap);
} }
@ -291,7 +294,7 @@ fatal(va_alist)
va_start(ap); va_start(ap);
{ {
char *fmt = va_arg(ap, char *); char *fmt = va_arg(ap, char *);
_error(FATAL, NULLNODE, fmt, ap); _error(FATAL, NULLNODE, fmt, ap, 0);
} }
va_end(ap); va_end(ap);
sys_stop(S_EXIT); sys_stop(S_EXIT);
@ -306,7 +309,7 @@ crash(va_alist)
va_start(ap); va_start(ap);
{ {
char *fmt = va_arg(ap, char *); char *fmt = va_arg(ap, char *);
_error(CRASH, NULLNODE, fmt, ap); _error(CRASH, NULLNODE, fmt, ap, 0);
} }
va_end(ap); va_end(ap);
#ifdef DEBUG #ifdef DEBUG
@ -317,18 +320,18 @@ crash(va_alist)
} }
#endif #endif
_error(class, node, fmt, ap) _error(class, node, fmt, ap, warn_class)
int class; int class;
t_node *node; t_node *node;
char *fmt; char *fmt;
register va_list ap; register va_list ap;
int warn_class;
{ {
/* _error attempts to limit the number of error messages /* _error attempts to limit the number of error messages
for a given line to MAXERR_LINE. for a given line to MAXERR_LINE.
*/ */
unsigned int ln = 0; unsigned int ln = 0;
register char *remark = 0; register char *remark = 0;
int warn_class;
/* check visibility of message */ /* check visibility of message */
if (class == ERROR || class == WARNING) { if (class == ERROR || class == WARNING) {
@ -355,7 +358,6 @@ _error(class, node, fmt, ap)
switch (class) { switch (class) {
case WARNING: case WARNING:
case LEXWARNING: case LEXWARNING:
warn_class = va_arg(ap, int);
if (! (warn_class & warning_classes)) return; if (! (warn_class & warning_classes)) return;
switch(warn_class) { switch(warn_class) {
#ifndef STRICT_3RD_ED #ifndef STRICT_3RD_ED

View file

@ -35,6 +35,7 @@ recognize some keywords!
extern int idfsize; extern int idfsize;
static int ndirs = 1; static int ndirs = 1;
int warning_classes = W_INITIAL; int warning_classes = W_INITIAL;
int gdb_flag;
DoOption(text) DoOption(text)
register char *text; register char *text;
@ -64,6 +65,10 @@ DoOption(text)
#ifdef DBSYMTAB #ifdef DBSYMTAB
case 'g': /* generate symbol table for debugger */ case 'g': /* generate symbol table for debugger */
options['g']++; options['g']++;
if (*text == 'd') {
/* Assume -gdb. */
gdb_flag = 1;
}
options['n']++; /* no register vars ??? */ options['n']++; /* no register vars ??? */
break; break;
#endif /* DBSYMTAB */ #endif /* DBSYMTAB */

View file

@ -27,6 +27,8 @@
#include "scope.h" #include "scope.h"
#include "main.h" #include "main.h"
extern int gdb_flag;
#define INCR_SIZE 64 #define INCR_SIZE 64
extern int proclevel; extern int proclevel;
@ -276,12 +278,34 @@ stb_string(df, kind)
addc_db_str(':'); addc_db_str(':');
switch(kind) { switch(kind) {
case D_MODULE: case D_MODULE:
adds_db_str(sprint(buf, "M%d;", df->mod_vis->sc_count)); if (gdb_flag) {
addc_db_str('F');
stb_type(void_type, 0);
addc_db_str(';');
}
else {
adds_db_str(sprint(buf, "M%d;", df->mod_vis->sc_count));
}
C_ms_stb_pnam(db_str.base, N_FUN, proclevel, df->mod_vis->sc_scope->sc_name); C_ms_stb_pnam(db_str.base, N_FUN, proclevel, df->mod_vis->sc_scope->sc_name);
break; break;
case D_PROCEDURE: case D_PROCEDURE:
adds_db_str(sprint(buf, "Q%d;", df->prc_vis->sc_count)); if (gdb_flag) {
addc_db_str('f');
}
else adds_db_str(sprint(buf, "Q%d;", df->prc_vis->sc_count));
stb_type(tp->tp_next ? tp->tp_next : void_type, 0); stb_type(tp->tp_next ? tp->tp_next : void_type, 0);
if (gdb_flag) {
t_scopelist *sc = df->prc_vis;
sc = enclosing(sc);
while (sc) {
t_def *d = sc->sc_scope->sc_definedby;
if (d && d->df_kind == D_PROCEDURE) {
adds_db_str(sprint(buf, ",%s", d->df_idf->id_text));
}
sc = enclosing(sc);
}
}
addc_db_str(';'); addc_db_str(';');
C_ms_stb_pnam(db_str.base, N_FUN, proclevel, df->prc_vis->sc_scope->sc_name); C_ms_stb_pnam(db_str.base, N_FUN, proclevel, df->prc_vis->sc_scope->sc_name);
{ {
@ -293,10 +317,12 @@ stb_string(df, kind)
} }
break; break;
case D_END: case D_END:
if (gdb_flag) break;
adds_db_str(sprint(buf, "E%d;", df->mod_vis->sc_count)); adds_db_str(sprint(buf, "E%d;", df->mod_vis->sc_count));
C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith) 0); C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith) 0);
break; break;
case D_PEND: case D_PEND:
if (gdb_flag) break;
adds_db_str(sprint(buf, "E%d;", df->prc_vis->sc_count)); adds_db_str(sprint(buf, "E%d;", df->prc_vis->sc_count));
C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith) 0); C_ms_stb_cst(db_str.base, N_SCOPE, proclevel, (arith) 0);
break; break;