ival.g
l_brace.str
l_class.h
+l_comment.h
l_comment.c
l_dummy.c
l_ev_ord.c
mes.h
options
options.c
+pragma.c
program.g
+proto.c
+proto.str
replace.c
+replace.str
scan.c
sizes.h
skip.c
!File: errout.h
#define ERROUT STDERR /* file pointer for writing messages */
-#define MAXERR_LINE 5 /* maximum number of error messages given
- on the same input line. */
+#define ERR_SHADOW 5 /* a syntax error overshadows error messages
+ until ERR_SHADOW symbols have been
+ accepted without syntax error */
!File: idfsize.h
/* Data about the token yielded */
struct token dot, ahead, aside;
+int token_nmb = 0; /* number of the ahead token */
+int tk_nmb_at_last_syn_err = -5/*ERR_SHADOW*/;
+ /* token number at last syntax error */
#ifndef NOPP
int ReplaceMacros = 1; /* replacing macros */
#define FLG_ESEEN 0x01 /* possibly a floating point number */
#define FLG_DOTSEEN 0x02 /* certainly a floating point number */
extern arith full_mask[];
-extern arith max_int;
#ifndef NOPP
static struct token LexStack[MAX_LL_DEPTH];
char buf[(IDFSIZE > NUMSIZE ? IDFSIZE : NUMSIZE) + 1];
register int ch, nch;
+ token_nmb++;
+
if (File_Inserted) {
File_Inserted = 0;
goto firstline;
case '!':
if (nch == '=')
return ptok->tk_symb = NOTEQUAL;
- UnGetChar();
- return ptok->tk_symb = ch;
+ break;
case '&':
if (nch == '&')
return ptok->tk_symb = AND;
- else if (nch == '=')
+ if (nch == '=')
return ptok->tk_symb = ANDAB;
- UnGetChar();
- return ptok->tk_symb = ch;
+ break;
case '+':
if (nch == '+')
return ptok->tk_symb = PLUSPLUS;
- else if (nch == '=')
+ if (nch == '=')
return ptok->tk_symb = PLUSAB;
- UnGetChar();
- return ptok->tk_symb = ch;
+ break;
case '-':
if (nch == '-')
return ptok->tk_symb = MINMIN;
- else if (nch == '>')
+ if (nch == '>')
return ptok->tk_symb = ARROW;
- else if (nch == '=')
+ if (nch == '=')
return ptok->tk_symb = MINAB;
- UnGetChar();
- return ptok->tk_symb = ch;
+ break;
case '<':
if (AccFileSpecifier) {
UnGetChar(); /* pushback nch */
ptok->tk_bts = string_token("file specifier",
'>', &(ptok->tk_len));
return ptok->tk_symb = FILESPECIFIER;
- } else if (nch == '<') {
+ }
+ if (nch == '<') {
if ((nch = GetChar()) == '=')
return ptok->tk_symb = LEFTAB;
UnGetChar();
}
if (nch == '=')
return ptok->tk_symb = LESSEQ;
- UnGetChar();
- return ptok->tk_symb = ch;
+ break;
case '=':
if (nch == '=')
return ptok->tk_symb = EQUAL;
- UnGetChar();
- return ptok->tk_symb = ch;
+ break;
case '>':
if (nch == '=')
return ptok->tk_symb = GREATEREQ;
UnGetChar();
return ptok->tk_symb = RIGHT;
}
- UnGetChar();
- return ptok->tk_symb = ch;
+ break;
case '|':
if (nch == '|')
return ptok->tk_symb = OR;
- else if (nch == '=')
+ if (nch == '=')
return ptok->tk_symb = ORAB;
- UnGetChar();
- return ptok->tk_symb = ch;
+ break;
case '%':
if (nch == '=')
return ptok->tk_symb = MODAB;
- UnGetChar();
- return ptok->tk_symb = ch;
+ break;
case '*':
if (nch == '=')
return ptok->tk_symb = TIMESAB;
- UnGetChar();
- return ptok->tk_symb = ch;
+ break;
case '^':
if (nch == '=')
return ptok->tk_symb = XORAB;
- UnGetChar();
- return ptok->tk_symb = ch;
+ break;
case '/':
if (nch == '*'
#ifndef NOPP
skipcomment();
goto again;
}
- else if (nch == '=')
+ if (nch == '=')
return ptok->tk_symb = DIVAB;
- UnGetChar();
- return ptok->tk_symb = ch;
+ break;
default:
crash("bad class for char 0%o", ch);
/* NOTREACHED */
}
+ UnGetChar();
+ return ptok->tk_symb = ch;
case STCHAR: /* character constant */
ptok->tk_ival = char_constant("character");
ptok->tk_fund = INT;
ch = GetChar();
}
if (size > 1)
- strict("%s constant includes more than one character", nm);
+ lexstrict("%s constant includes more than one character", nm);
if (size > (int)int_size)
lexerror("%s constant too long", nm);
return val;
#define tk_fval tok_data.tok_fval
extern struct token dot, ahead, aside;
+extern int token_nmb; /* number of the ahead token */
+extern int tk_nmb_at_last_syn_err; /* token number at last syntax error */
#ifndef NOPP
extern int ReplaceMacros; /* "LLlex.c" */
error("%s missing", symbol2str(tk));
insert_token(tk);
}
- else
+ else {
error("%s deleted", symbol2str(DOT));
+ }
+ tk_nmb_at_last_syn_err = token_nmb;
}
insert_token(tk)
!File: errout.h
#define ERROUT STDERR /* file pointer for writing messages */
-#define MAXERR_LINE 5 /* maximum number of error messages given
- on the same input line. */
+#define ERR_SHADOW 0 /* a syntax error overshadows error messages
+ until ERR_SHADOW symbols have been
+ accepted without syntax error */
!File: idfsize.h
LINT = /usr/bin/lint
LINTFLAGS =
-MYLINT = ../lpass2/lint
-MYLINTFLAGS = -xh
-
#EXCLEXCLEXCLEXCL
.SUFFIXES: .str .h
$(CFLOW) $(CDEFS) $(SRC)
lint: Cfiles
- sh -c 'if $(CC) nmclash.c > /dev/null 2>&1 ; then make "EMHOME="$(EMHOME) Xlint ; else sh Resolve Xlint ; fi'
- @rm -f nmclash.o a.out
-
-mylint: Cfiles
- sh -c 'if $(CC) nmclash.c > /dev/null 2>&1 ; then make "EMHOME="$(EMHOME) Xmylint ; else sh Resolve Xmylint ; fi'
+ sh -c 'if $(CC) nmclash.c > /dev/null 2>&1 ; then make "EMHOME="$(EMHOME) LINT=$(LINT) LINTFLAGS=$(LINTFLAGS) Xlint ; else sh Resolve Xlint ; fi'
@rm -f nmclash.o a.out
longnames: $(SRC) $(HFILES)
Xlint: $(SRC)
$(LINT) $(CDEFS) $(LINTFLAGS) $(SRC)
-Xmylint: $(SRC)
- $(MYLINT) $(CDEFS) $(MYLINTFLAGS) $(SRC)
-
#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
main.o: LLlex.h
main.o: Lpars.h
expr.o: spec_arith.h
expr.o: target_sizes.h
expr.o: type.h
+expr.o: use_tmp.h
ch3.o: Lpars.h
ch3.o: arith.h
ch3.o: assert.h
!File: errout.h
#define ERROUT STDERR /* file pointer for writing messages */
-#define MAXERR_LINE 5 /* maximum number of error messages given
- on the same input line. */
+#define ERR_SHADOW 5 /* a syntax error overshadows error messages
+ until ERR_SHADOW symbols have been
+ accepted without syntax error */
!File: idfsize.h
exp->ex_type = tp;
exp->ex_class = Float;
- /* exp->FL_VALUE = 0 /* Salloc(buf, (unsigned)strlen(buf)+1) */ ;
+ exp->FL_VALUE = 0;
flt_arith2flt(exp->VL_VALUE, &(exp->FL_ARITH));
- /* exp->FL_DATLAB = 0; */
+ exp->FL_DATLAB = 0;
}
else *expp = arith2arith(tp, INT2FLOAT, *expp);
}
register struct type *oldtp;
if (oper == RETURN && tp->tp_fund == VOID) {
- strict("return <expression> in function returning void");
+ expr_strict(*expp, "return <expression> in function returning void");
(*expp)->ex_type = void_type;
return;
}
if (!exp->ex_lvalue) {
expr_error(exp, "no lvalue in operand of %s", oper_string);
} else if (exp->ex_flags & EX_ILVALUE) {
- strict("incorrect lvalue in operand of %s", oper_string);
+ expr_strict(exp, "incorrect lvalue in operand of %s", oper_string);
} else if (exp->ex_flags & EX_READONLY) {
expr_error(exp, "operand of %s is read-only", oper_string);
} else if (fund == STRUCT || fund == UNION) {
if (def_sc == TYPEDEF) /* no code for typedefs */
return;
-#ifndef PREPEND_SCOPES
- if (fund == FUNCTION) {
- code_scope(idf->id_text, def);
- }
-#endif PREPEND_SCOPES
if (lvl == L_GLOBAL) { /* global variable */
/* is this an allocating declaration? */
if ( (sc == 0 || sc == STATIC)
case GLOBAL:
case IMPLICIT:
/* we are sure there is no expression */
-#ifndef PREPEND_SCOPES
- code_scope(idf->id_text, def);
-#endif PREPEND_SCOPES
break;
case AUTO:
case REGISTER:
#include "assert.h"
arith full_mask[MAXSIZE];/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */
+#ifndef NOCROSS
arith max_int; /* maximum integer on target machine */
arith max_unsigned; /* maximum unsigned on target machine */
+#endif /* NOCROSS */
extern int ResultKnown;
cstbin(expp, oper, expr)
}
if ((int)long_size > arith_size)
fatal("sizeof (arith) insufficient on this machine");
+#ifndef NOCROSS
max_int = full_mask[(int)int_size] & ~(1L << ((int)int_size * 8 - 1));
max_unsigned = full_mask[(int)int_size];
+#endif /* NOCROSS */
}
extern char options[];
extern int level;
extern char *symbol2str();
-extern char *type2str();
-extern char *qual2str();
extern struct type *qualifier_type();
struct decspecs null_decspecs;
if (!to_endif && nestlevel == skiplevel) {
if (SkipToNewLine())
if (!options['o'])
- strict("garbage following #else");
+ lexstrict("garbage following #else");
NoUnstack--;
return;
}
if (nestlevel == skiplevel) {
if (SkipToNewLine())
if (!options['o'])
- strict("garbage following #endif");
+ lexstrict("garbage following #endif");
nestlevel--;
NoUnstack--;
return;
{
if (SkipToNewLine())
if (!options['o'])
- strict("garbage following #else");
+ lexstrict("garbage following #else");
if (nestlevel <= nestlow)
lexerror("#else without corresponding #if");
else { /* mark this level as else-d */
{
if (SkipToNewLine())
if (!options['o'])
- strict("garbage following #endif");
+ lexstrict("garbage following #endif");
if (nestlevel <= nestlow) {
lexerror("#endif without corresponding #if");
}
va_end(ap);
}
+/*VARARGS*/
+lexstrict(va_alist)
+ va_dcl
+{
+ va_list ap;
+
+ va_start(ap);
+ {
+ _error(STRICT, FileName, LineNumber, ap);
+ }
+ va_end(ap);
+}
+
/*VARARGS*/
strict(va_alist)
va_dcl
va_end(ap);
}
+/*VARARGS*/
+expr_strict(va_alist) /* expr, fmt, args */
+ va_dcl
+{
+ va_list ap;
+
+ va_start(ap);
+ {
+ struct expr *expr = va_arg(ap, struct expr *);
+
+ if (!(expr->ex_flags & EX_ERROR)) {
+ /* to prevent proliferation */
+ _error(STRICT, expr->ex_file, expr->ex_line, ap);
+ }
+ }
+ va_end(ap);
+}
+
#ifdef DEBUG
/*VARARGS*/
debug(va_alist)
unsigned int ln;
va_list ap;
{
- /* _error attempts to limit the number of error messages
- for a given line to MAXERR_LINE.
- */
-#ifndef LINT
- static char *last_fn = 0;
- static unsigned int last_ln = 0;
- static int e_seen = 0;
-#endif LINT
char *remark;
char *fmt = va_arg(ap, char *);
+ /* check visibility of message */
+ switch (class) {
+ case WARNING:
+ case ERROR:
+ case STRICT:
+ if (token_nmb < tk_nmb_at_last_syn_err + ERR_SHADOW)
+ /* warning or error message overshadowed */
+ return;
+ break;
+ }
+
/* Since name and number are gathered from different places
depending on the class, we first collect the relevant
values and then decide what to print.
/*NOTREACHED*/;
}
-#ifndef LINT
- if (class != DO_DEBUG) /* ??? DEBUG */
- if (ln == last_ln && fn && last_fn && strcmp(fn, last_fn) == 0) {
- /* we've seen this place before */
- e_seen++;
- if (e_seen == MAXERR_LINE)
- fmt = "etc ...";
- else
- if (e_seen > MAXERR_LINE)
- /* and too often, I'd say ! */
- return;
- }
- else {
- /* brand new place */
- last_fn = fn;
- last_ln = ln;
- e_seen = 0;
- }
-#endif LINT
-
#ifdef LINT
if ( /* there is a file name */
fn
case PLUSPLUS:
case MINMIN:
{
- arith tmp;
+ arith tmp = 0;
int compl; /* Complexity of left operand */
int newcode = left->ex_type->tp_size > 0; /* CJ */
#ifndef NOBITFIELD
register struct value *vl;
register struct type *tp;
{
- int al_on_word;
- register int inword;
- register int indword;
+ register int inword = 0;
+ register int indword = 0;
arith val = vl->vl_value;
if (vl->vl_class == Const) { /* absolute addressing */
store_block(tp->tp_size, tp->tp_align);
return;
}
- al_on_word = (tp->tp_align % word_align == 0);
- if (!(inword = (tp->tp_size == word_size && al_on_word)))
- indword = (tp->tp_size == dword_size && al_on_word);
+ if (tp->tp_align % word_align == 0) {
+ if (tp->tp_size == word_size) inword = 1;
+ else if (tp->tp_size == dword_size) indword = 1;
+ }
if (vl->vl_class == Name) {
register struct idf *id = vl->vl_data.vl_idf;
register struct def *df = id->id_def;
{
register struct type *tp = expr->ex_type;
int rvalue = (rlval == RVAL && expr->ex_lvalue != 0);
- int al_on_word;
- register int inword, indword;
+ register int inword = 0, indword = 0;
register arith val = expr->VL_VALUE;
if (expr->VL_CLASS == Const) {
return;
}
if (rvalue) {
- al_on_word = (tp->tp_align % word_align == 0);
- if (!(inword = (tp->tp_size == word_size && al_on_word)))
- indword = (tp->tp_size == dword_size && al_on_word);
+ if (tp->tp_align % word_align == 0) {
+ if (tp->tp_size == word_size) inword = 1;
+ else if (tp->tp_size == dword_size) indword = 1;
+ }
}
if (expr->VL_CLASS == Label) {
if (rvalue) {
#include "declar.h"
#include "sizes.h"
#include "level.h"
+#include "use_tmp.h"
extern char *symbol2str();
extern char options[];
}
else {
#ifndef LINT
- if (!InSizeof)
- def->df_used = 1;
+ if (!InSizeof) {
+ if (! def->df_used) {
+#ifndef PREPEND_SCOPES
+ code_scope(idf->id_text, def);
+#endif /* PREPEND_SCOPES */
+ def->df_used = 1;
+ }
+ }
#endif LINT
expr->ex_type = def->df_type;
if (expr->ex_type == error_type) {
register struct expr *rightop = expr->OP_RIGHT;
register struct field *fd = leftop->ex_type->tp_field;
struct type *tp = leftop->ex_type->tp_up;
- arith tmpvar;
+ arith tmpvar = 0;
struct type *atype = tp->tp_unsigned ? uword_type : word_type;
/* First some assertions to be sure that the rest is legal */
*/
flt_arith o1, o2;
int compar = 0;
- int cmpval;
+ int cmpval = 0;
o1 = (*expp)->FL_ARITH;
o2 = expr->FL_ARITH;
error("incorrect number of parameters");
}
} else { /* make a pseudo-prototype */
- register struct proto *lpl;
+ register struct proto *lpl = new_proto();
while (fm) {
- if (pl == 0) pl = lpl = new_proto();
+ if (pl == 0) pl = lpl;
else {
lpl->next = new_proto();
lpl = lpl->next;
fm = fm->next;
}
if (pl == 0) { /* make func(void) */
- pl = new_proto();
+ pl = lpl;
pl->pl_type = void_type;
pl->pl_flag = PL_VOID;
}
tp = localtime(&clock);
/* __DATE__ */
- sprintf(dbuf, "\"%.3s %.2d %d\"", months[tp->tm_mon],
+ sprint(dbuf, "\"%s %02d %d\"", months[tp->tm_mon],
tp->tm_mday, tp->tm_year+1900);
if (tp->tm_mday < 10) dbuf[5] = ' '; /* hack */
macro_def(str2idf("__DATE__"), dbuf, -1, strlen(dbuf), NOUNDEF);
/* __TIME__ */
- sprintf(tbuf, "\"%.2d:%.2d:%.2d\"", tp->tm_hour, tp->tm_min, tp->tm_sec);
+ sprint(tbuf, "\"%02d:%02d:%02d\"", tp->tm_hour, tp->tm_min, tp->tm_sec);
macro_def(str2idf("__TIME__"), tbuf, -1, strlen(tbuf), NOUNDEF);
/* __LINE__ */
#define INP_TYPE struct file_info
#define INP_VAR finfo
struct file_info finfo;
-extern int nestlevel;
#include "nopp.h"
#include <inp_pkg.body>
}
int InputLevel;
+extern int nestlevel;
#endif NOPP
int NoUnstack;
char *strncpy();
extern char options[];
static int gen_error;
+static int pack_level;
struct type **gen_tphead(), **gen_tpmiddle();
struct sdef *gen_align_to_next();
struct e_stack *p_stack;
/* initial_value recursively guides the initialisation expression.
*/
/* 3.5 */
-{ static int pack_level; }
initial_value(register struct type **tpp; register struct expr **expp;) :
{ if (tpp) gen_tpcheck(tpp); }
p_stack = p;
}
}
+ if (pack_level < gen_error) gen_error = 0;
}
'}'
;
switch((tp = *tpp)->tp_fund) {
case ARRAY:
if (! valid_type(tp->tp_up, "array element"))
- gen_error = 1;
+ gen_error = pack_level;
break;
case STRUCT:
if (! valid_type(tp, "struct"))
- gen_error = 1;
+ gen_error = pack_level;
break;
case UNION:
if (! valid_type(tp, "union"))
- gen_error = 1;
+ gen_error = pack_level;
break;
}
}
check_and_pad(expp, tpp);
break;
case ERRONEOUS:
- gen_error = 1;
+ gen_error = pack_level;
break;
default:
check_ival(expp, tp);
register struct sdef *sd;
if (tpp && *tpp == error_type) {
- gen_error = 1;
+ gen_error = pack_level;
return 0;
}
if (gen_error) return tpp;
#endif
if (! sd) {
/* something wrong with this struct */
- gen_error = 1;
+ gen_error = pack_level;
p_stack = p->next;
free_e_stack(p);
return 0;
free_e_stack(p_stack);
p_stack = p;
}
- gen_error = 0;
}
/* check_and_pad() is given a simple initialisation expression
struct expr *ex;
{
expr_error(ex, "illegal initialisation constant");
- gen_error = 1;
+ gen_error = pack_level;
}
too_many_initialisers()
{
error("too many initialisers");
- gen_error = 1;
+ gen_error = pack_level;
}
}
}
}
-add_proto(pl, ds, dc, level)
+add_proto(pl, ds, dc, lvl)
struct proto *pl;
struct decspecs *ds;
struct declarator *dc;
- int level;
+ int lvl;
{
/* The full typed identifier or abstract type, described
by the structures decspecs and declarator are turned
sc = (ds->ds_sc_given && ds->ds_sc != REGISTER) ?
0 : sc == 0 ? FORMAL : REGISTER;
- if (def && (def->df_level == level /* || def->df_level < L_PROTO */ )) {
+ if (def && (def->df_level == lvl /* || def->df_level < L_PROTO */ )) {
/* redeclaration at the same level */
error("parameter %s redeclared", idf->id_text);
} else if (idf != (struct idf *)0) {
register struct def *newdef = new_def();
newdef->next = def;
- newdef->df_level = level;
+ newdef->df_level = lvl;
newdef->df_sc = sc;
newdef->df_type = type;
newdef->df_formal_array = formal_array;
/* stack up the parameter expressions */
while (right->ex_class == Oper && right->OP_OPER == PARCOMMA) {
if (ecnt == STDC_NPARAMS)
- strict("number of parameters exceeds ANSI limit");
+ expr_strict(right, "number of parameters exceeds ANSI limit");
if (ecnt >= NPARAMS-1) {
- error("too many parameters");
+ expr_error(right, "too many parameters");
return;
}
estack[ecnt++] = &(right->OP_RIGHT);
parameters.
*/
if (pl && pl->pl_flag & PL_VOID) {
- strict("no parameters expected");
+ expr_strict(*expp, "no parameters expected");
pl = NO_PROTO;
}
checked nor converted !
*/
if (pcnt < 0) {
- error("more parameters than specified in prototype");
+ expr_error(*expp, "more parameters than specified in prototype");
break;
}
else if (!(pstack[pcnt]->pl_flag & PL_ELLIPSIS)) {
any2parameter(estack[ecnt]);
}
if (pcnt >= 0 && !(pstack[0]->pl_flag & PL_ELLIPSIS))
- error("less parameters than specified in prototype");
+ expr_error(*expp, "less parameters than specified in prototype");
} else {
if (pl && !(pl->pl_flag & PL_VOID))
- error("less parameters than specified in prototype");
+ expr_error(*expp, "less parameters than specified in prototype");
}
}
extern struct idf *GetIdentifier();
extern int InputLevel;
struct repl *ReplaceList; /* list of currently active macros */
+extern char *strcat(), *strcpy();
int
replace(idf)
args->a_expvec[argcnt] = args->a_expptr;
args->a_rawvec[argcnt] = args->a_rawptr;
if (argcnt == STDC_NPARAMS)
- strict("number of parameters exceeds ANSI standard");
+ lexstrict("number of parameters exceeds ANSI standard");
if (argcnt >= NPARAMS)
fatal("argument vector overflow");
}
short_size, word_size, dword_size, int_size, long_size,
float_size, double_size, lngdbl_size,
pointer_size;
+
+extern arith max_int, max_unsigned; /* cstoper.c */
#else NOCROSS
#define short_size (SZ_SHORT)
#define word_size (SZ_WORD)
#define double_size (SZ_DOUBLE)
#define lngdbl_size (SZ_LNGDBL)
#define pointer_size (SZ_POINTER)
+
+#if int_size == 2
+#define max_int ((arith)32767)
+#define max_unsigned ((arith)65535)
+#else /* int_size == 4 */
+#define max_int ((arith)2147483647)
+#define max_unsigned ((arith)4294967295)
+#endif
#endif NOCROSS
-extern arith max_int, max_unsigned; /* cstoper.c */