many little changes: removed some lint complaints; max_int and max_unsigned
authorceriel <none@none>
Wed, 8 Nov 1989 16:52:34 +0000 (16:52 +0000)
committerceriel <none@none>
Wed, 8 Nov 1989 16:52:34 +0000 (16:52 +0000)
are now constants if NOCROSS is defined; added lexstrict and expr_strict,
and changed calls where needed

26 files changed:
lang/cem/cemcom.ansi/.distr
lang/cem/cemcom.ansi/BigPars
lang/cem/cemcom.ansi/LLlex.c
lang/cem/cemcom.ansi/LLlex.h
lang/cem/cemcom.ansi/LLmessage.c
lang/cem/cemcom.ansi/LintPars
lang/cem/cemcom.ansi/Makefile
lang/cem/cemcom.ansi/SmallPars
lang/cem/cemcom.ansi/arith.c
lang/cem/cemcom.ansi/ch3.c
lang/cem/cemcom.ansi/code.c
lang/cem/cemcom.ansi/cstoper.c
lang/cem/cemcom.ansi/decspecs.c
lang/cem/cemcom.ansi/domacro.c
lang/cem/cemcom.ansi/error.c
lang/cem/cemcom.ansi/eval.c
lang/cem/cemcom.ansi/expr.c
lang/cem/cemcom.ansi/field.c
lang/cem/cemcom.ansi/fltcstoper.c
lang/cem/cemcom.ansi/idf.c
lang/cem/cemcom.ansi/init.c
lang/cem/cemcom.ansi/input.c
lang/cem/cemcom.ansi/ival.g
lang/cem/cemcom.ansi/proto.c
lang/cem/cemcom.ansi/replace.c
lang/cem/cemcom.ansi/sizes.h

index 0aa72f0..fd99368 100644 (file)
@@ -54,6 +54,7 @@ interface.h
 ival.g
 l_brace.str
 l_class.h
+l_comment.h
 l_comment.c
 l_dummy.c
 l_ev_ord.c
@@ -78,8 +79,12 @@ mcomm.c
 mes.h
 options
 options.c
+pragma.c
 program.g
+proto.c
+proto.str
 replace.c
+replace.str
 scan.c
 sizes.h
 skip.c
index fb6ecb2..ef12fed 100644 (file)
@@ -8,8 +8,9 @@
 
 !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
index b5ca0e0..5073bc3 100644 (file)
@@ -25,6 +25,9 @@
 
 /* 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                     */
@@ -42,7 +45,6 @@ int LexSave = 0;              /* last character read by GetChar       */
 #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];
@@ -114,6 +116,8 @@ GetToken(ptok)
        char buf[(IDFSIZE > NUMSIZE ? IDFSIZE : NUMSIZE) + 1];
        register int ch, nch;
 
+       token_nmb++;
+
        if (File_Inserted) {
                File_Inserted = 0;
                goto firstline;
@@ -178,38 +182,35 @@ garbage:
                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();
@@ -217,13 +218,11 @@ garbage:
                        }
                        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;
@@ -233,30 +232,25 @@ garbage:
                                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
@@ -266,14 +260,15 @@ garbage:
                                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;
@@ -508,7 +503,7 @@ char_constant(nm)
                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;
index a453959..bcdfb5b 100644 (file)
@@ -41,6 +41,8 @@ struct token  {
 #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"    */
index c72f47d..8e89113 100644 (file)
@@ -22,8 +22,10 @@ LLmessage(tk)        {
                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)
index 14f4838..e3de245 100644 (file)
@@ -8,8 +8,9 @@
 
 !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
index cc40680..9f59caf 100644 (file)
@@ -140,9 +140,6 @@ SRC =       $(CSRC) $(LCSRC) $(GCSRC)
 LINT = /usr/bin/lint
 LINTFLAGS =
 
-MYLINT = ../lpass2/lint
-MYLINTFLAGS = -xh
-
 #EXCLEXCLEXCLEXCL
 
 .SUFFIXES: .str .h
@@ -198,11 +195,7 @@ cflow:     Cfiles
        $(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)
@@ -284,9 +277,6 @@ $(CURRDIR)lnt:              $(OBJ) $(CURRDIR)Makefile
 Xlint: $(SRC)
        $(LINT) $(CDEFS) $(LINTFLAGS) $(SRC)
 
-Xmylint:       $(SRC)
-       $(MYLINT) $(CDEFS) $(MYLINTFLAGS) $(SRC)
-
 #AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
 main.o: LLlex.h
 main.o: Lpars.h
@@ -414,6 +404,7 @@ expr.o: sizes.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
index 5dcb139..78ff595 100644 (file)
@@ -8,8 +8,9 @@
 
 !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
index de693a8..4fb0f3c 100644 (file)
@@ -334,9 +334,9 @@ int2float(expp, tp)
                
                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);
 }
index b234070..ecec52d 100644 (file)
@@ -172,7 +172,7 @@ ch3cast(expp, oper, tp)
        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;
        }
@@ -554,7 +554,7 @@ ch3asgn(expp, oper, expr)
        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) {
index 442c19e..d0e75d4 100644 (file)
@@ -375,11 +375,6 @@ code_declaration(idf, expr, lvl, sc)
        
        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)
@@ -429,9 +424,6 @@ code_declaration(idf, expr, lvl, sc)
                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:
index 0162a16..ecc7ae5 100644 (file)
 #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)
@@ -251,6 +253,8 @@ init_cst()
        }
        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 */
 }
index 36e9284..fe088f9 100644 (file)
@@ -16,8 +16,6 @@
 extern char options[];
 extern int level;
 extern char *symbol2str();
-extern char *type2str();
-extern char *qual2str();
 extern struct type *qualifier_type();
 
 struct decspecs null_decspecs;
index a24259d..788a93a 100644 (file)
@@ -213,7 +213,7 @@ int to_endif;
                        if (!to_endif && nestlevel == skiplevel) {
                                if (SkipToNewLine())
                                        if (!options['o'])
-                                               strict("garbage following #else");
+                                               lexstrict("garbage following #else");
                                NoUnstack--;
                                return;
                        }
@@ -224,7 +224,7 @@ int to_endif;
                        if (nestlevel == skiplevel) {
                                if (SkipToNewLine())
                                        if (!options['o'])
-                                               strict("garbage following #endif");
+                                               lexstrict("garbage following #endif");
                                nestlevel--;
                                NoUnstack--;
                                return;
@@ -368,7 +368,7 @@ do_else()
 {
        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 */
@@ -384,7 +384,7 @@ do_endif()
 {
        if (SkipToNewLine())
                if (!options['o'])
-                       strict("garbage following #endif");
+                       lexstrict("garbage following #endif");
        if (nestlevel <= nestlow)       {
                lexerror("#endif without corresponding #if");
        }
index 131d24c..85374e3 100644 (file)
@@ -87,6 +87,19 @@ expr_error(va_alist)                 /* expr, fmt, args */
        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
@@ -100,6 +113,24 @@ strict(va_alist)
        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)
@@ -269,17 +300,20 @@ _error(class, fn, ln, ap)
        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.
@@ -338,26 +372,6 @@ _error(class, fn, ln, ap)
                /*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
index cc4bb4f..b0f196c 100644 (file)
@@ -387,7 +387,7 @@ EVAL(expr, val, code, true_label, false_label)
                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
@@ -803,9 +803,8 @@ store_val(vl, tp)
        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 */
@@ -813,9 +812,10 @@ store_val(vl, tp)
                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;
@@ -877,8 +877,7 @@ load_val(expr, rlval)
 {
        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) {
@@ -891,9 +890,10 @@ load_val(expr, rlval)
                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) {
index dc863cb..311e261 100644 (file)
@@ -22,6 +22,7 @@
 #include       "declar.h"
 #include       "sizes.h"
 #include       "level.h"
+#include       "use_tmp.h"
 
 extern char *symbol2str();
 extern char options[];
@@ -157,8 +158,14 @@ idf2expr(expr)
        }
        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) {
index 4720f34..ac7a932 100644 (file)
@@ -51,7 +51,7 @@ eval_field(expr, code)
        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 */
index f126cdb..680b636 100644 (file)
@@ -31,7 +31,7 @@ fltcstbin(expp, oper, expr)
        */
        flt_arith o1, o2;
        int compar = 0;
-       int cmpval;
+       int cmpval = 0;
 
        o1 = (*expp)->FL_ARITH;
        o2 = expr->FL_ARITH;
index dd49b99..5ca36b9 100644 (file)
@@ -623,10 +623,10 @@ check_formals(idf, dc)
                        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;
@@ -638,7 +638,7 @@ check_formals(idf, dc)
                        fm = fm->next;
                }
                if (pl == 0) {          /* make func(void) */
-                       pl = new_proto();
+                       pl = lpl;
                        pl->pl_type = void_type;
                        pl->pl_flag = PL_VOID;
                }
index 5b30f95..96bb981 100644 (file)
@@ -70,13 +70,13 @@ init_pp()
        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__     */
index 8ff07ce..756c22e 100644 (file)
@@ -12,7 +12,6 @@
 #define INP_TYPE       struct file_info
 #define INP_VAR                finfo
 struct file_info       finfo;
-extern int             nestlevel;
 #include "nopp.h"
 #include <inp_pkg.body>
 
@@ -42,6 +41,7 @@ getwdir(fn)
 }
 
 int    InputLevel;
+extern int             nestlevel;
 #endif NOPP
 
 int    NoUnstack;
index cfaff03..fdee44a 100644 (file)
@@ -39,6 +39,7 @@ char *long2str();
 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;
@@ -47,7 +48,6 @@ 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); }
@@ -85,6 +85,7 @@ initial_value_pack(struct type **tpp; struct expr **expp;)
                                        p_stack = p;
                                }
                          }
+                         if (pack_level < gen_error) gen_error = 0;
                        }
        '}'
 ;
@@ -117,15 +118,15 @@ gen_tpcheck(tpp)
        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;
        }
 }
@@ -150,7 +151,7 @@ gen_simple_exp(tpp, expp)
                check_and_pad(expp, tpp);
                break;
        case ERRONEOUS:
-               gen_error = 1;
+               gen_error = pack_level;
                break;
        default:
                check_ival(expp, tp);
@@ -198,7 +199,7 @@ gen_tphead(tpp, nest)
        register struct sdef *sd;
 
        if (tpp && *tpp == error_type) {
-               gen_error = 1;
+               gen_error = pack_level;
                return 0;
        }
        if (gen_error) return tpp;
@@ -227,7 +228,7 @@ gen_tphead(tpp, nest)
 #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;
@@ -356,7 +357,6 @@ gen_tpend()
            free_e_stack(p_stack);
            p_stack = p;
        }
-       gen_error = 0;
 }
 
 /*     check_and_pad() is given a simple initialisation expression
@@ -690,12 +690,12 @@ illegal_init_cst(ex)
        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;
 }
 }
index 5864133..36cfed1 100644 (file)
@@ -49,11 +49,11 @@ check_for_void(pl)
        }
 }
 
-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
@@ -102,7 +102,7 @@ add_proto(pl, ds, dc, level)
        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) {
@@ -111,7 +111,7 @@ add_proto(pl, ds, dc, level)
                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;
@@ -412,9 +412,9 @@ call_proto(expp)
                /* 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);
@@ -427,7 +427,7 @@ call_proto(expp)
                        parameters.
                */
                if (pl && pl->pl_flag & PL_VOID) {
-                       strict("no parameters expected");
+                       expr_strict(*expp, "no parameters expected");
                        pl = NO_PROTO;
                }
 
@@ -451,7 +451,7 @@ call_proto(expp)
                                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)) {
@@ -461,10 +461,10 @@ call_proto(expp)
                                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");
        }
 }
index 7fcc8dc..62cf2b6 100644 (file)
@@ -30,6 +30,7 @@
 extern struct idf *GetIdentifier();
 extern int InputLevel;
 struct repl *ReplaceList;      /* list of currently active macros */
+extern char *strcat(), *strcpy();
 
 int
 replace(idf)
@@ -221,7 +222,7 @@ getactuals(repl, 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");
                }
index 0a608c8..e23951e 100644 (file)
@@ -13,6 +13,8 @@ extern arith
        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)
@@ -23,6 +25,13 @@ extern arith
 #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    */