initial small modifications for lint

This commit is contained in:
dick 1988-08-19 13:55:22 +00:00
parent e8730266e5
commit 1a6665e21d
19 changed files with 94 additions and 62 deletions

View file

@ -52,8 +52,6 @@ PushLex()
ASSERT(LexSP < 2); ASSERT(LexSP < 2);
ASSERT(ASIDE == 0); /* ASIDE = 0; */ ASSERT(ASIDE == 0); /* ASIDE = 0; */
GetToken(&ahead); GetToken(&ahead);
ahead.tk_line = LineNumber;
ahead.tk_file = FileName;
LexStack[LexSP++] = dot; LexStack[LexSP++] = dot;
} }
@ -87,9 +85,6 @@ LLlex()
else else
DOT = EOF; DOT = EOF;
} }
/* keep track of the place of the token in the file */
ahead.tk_file = FileName;
ahead.tk_line = LineNumber;
return DOT; return DOT;
} }
@ -111,6 +106,7 @@ GetToken(ptok)
File_Inserted = 0; File_Inserted = 0;
goto firstline; goto firstline;
} }
again: /* rescan the input after an error or replacement */ again: /* rescan the input after an error or replacement */
#ifndef NOPP #ifndef NOPP
if (Unstacked) EnableMacros(); if (Unstacked) EnableMacros();
@ -119,10 +115,16 @@ again: /* rescan the input after an error or replacement */
go_on: /* rescan, the following character has been read */ go_on: /* rescan, the following character has been read */
if ((ch & 0200) && ch != EOI) /* stop on non-ascii character */ if ((ch & 0200) && ch != EOI) /* stop on non-ascii character */
fatal("non-ascii '\\%03o' read", ch & 0377); fatal("non-ascii '\\%03o' read", ch & 0377);
/* keep track of the place of the token in the file */
ptok->tk_file = FileName;
ptok->tk_line = LineNumber;
switch (class(ch)) { /* detect character class */ switch (class(ch)) { /* detect character class */
case STNL: /* newline, vertical space or formfeed */ case STNL: /* newline, vertical space or formfeed */
firstline: firstline:
LineNumber++; /* also at vs and ff */ LineNumber++; /* also at vs and ff */
ptok->tk_file = FileName;
ptok->tk_line = LineNumber;
if (EoiForNewline) /* called in control line */ if (EoiForNewline) /* called in control line */
/* a newline in a control line indicates the /* a newline in a control line indicates the
end-of-information of the line. end-of-information of the line.

View file

@ -160,3 +160,4 @@ copy_loop(sz, src, dst)
C_asp(word_size); C_asp(word_size);
} }
#endif STB #endif STB

View file

@ -464,11 +464,11 @@ loc_init(expr, id)
ch7cast(&expr, '=', tp); /* may modify expr */ ch7cast(&expr, '=', tp); /* may modify expr */
EVAL(expr, RVAL, TRUE, NO_LABEL, NO_LABEL); EVAL(expr, RVAL, TRUE, NO_LABEL, NO_LABEL);
free_expression(expr);
vl.vl_class = Name; vl.vl_class = Name;
vl.vl_data.vl_idf = id; vl.vl_data.vl_idf = id;
vl.vl_value = (arith)0; vl.vl_value = (arith)0;
store_val(&vl, tp); store_val(&vl, tp);
free_expression(expr);
} }
} }

View file

@ -125,7 +125,7 @@ conversion(from_type, to_type)
signed, unsigned or floating signed, unsigned or floating
*/ */
int int
fundamental(tp) fundamental(tp)/* bad name ???*/
register struct type *tp; register struct type *tp;
{ {
switch (tp->tp_fund) { switch (tp->tp_fund) {
@ -146,3 +146,4 @@ fundamental(tp)
} }
return 0; return 0;
} }

View file

@ -11,6 +11,8 @@
#include "debug.h" #include "debug.h"
#include "arith.h" #include "arith.h"
#include "LLlex.h" #include "LLlex.h"
#include "label.h"
#include "code.h"
#include "idf.h" #include "idf.h"
#include "type.h" #include "type.h"
#include "struct.h" #include "struct.h"
@ -126,10 +128,10 @@ single_type_specifier(register struct decspecs *ds;):
IDENTIFIER IDENTIFIER
{ {
error("%s is not a type identifier", dot.tk_idf->id_text); error("%s is not a type identifier", dot.tk_idf->id_text);
ds->ds_type = error_type; ds->ds_type = error_type;
if (dot.tk_idf->id_def) { if (dot.tk_idf->id_def) {
dot.tk_idf->id_def->df_type = error_type; dot.tk_idf->id_def->df_type = error_type;
dot.tk_idf->id_def->df_sc = TYPEDEF; dot.tk_idf->id_def->df_sc = TYPEDEF;
} }
} }
| |
@ -164,7 +166,9 @@ init_declarator(register struct decspecs *ds;)
{ code_declaration(Dc.dc_idf, (struct expr *) 0, level, ds->ds_sc); } { code_declaration(Dc.dc_idf, (struct expr *) 0, level, ds->ds_sc); }
] ]
] ]
{remove_declarator(&Dc);} {
remove_declarator(&Dc);
}
; ;
/* 8.6: initializer */ /* 8.6: initializer */
@ -189,10 +193,11 @@ initializer(struct idf *idf; int sc;)
external_definition, q.v. external_definition, q.v.
*/ */
] ]
{ if (globalflag) { {
if (globalflag) {
struct expr ex; struct expr ex;
code_declaration(idf, &ex, level, sc); code_declaration(idf, &ex, level, sc);
} }
} }
initial_value(globalflag ? &(idf->id_def->df_type) : (struct type **)0, initial_value(globalflag ? &(idf->id_def->df_type) : (struct type **)0,
&expr) &expr)
@ -205,8 +210,8 @@ initializer(struct idf *idf; int sc;)
print_expr("initializer-expression", expr); print_expr("initializer-expression", expr);
#endif DEBUG #endif DEBUG
code_declaration(idf, expr, level, sc); code_declaration(idf, expr, level, sc);
} }
init_idf(idf); init_idf(idf);
} }
; ;

View file

@ -5,6 +5,7 @@
/* $Header$ */ /* $Header$ */
/* IDENTIFIER DEFINITION DESCRIPTOR */ /* IDENTIFIER DEFINITION DESCRIPTOR */
struct def { /* for ordinary tags */ struct def { /* for ordinary tags */
struct def *next; struct def *next;
int df_level; int df_level;

View file

@ -17,6 +17,7 @@
#include "arith.h" #include "arith.h"
#include "label.h" #include "label.h"
#include "expr.h" #include "expr.h"
#include "def.h"
#include "LLlex.h" #include "LLlex.h"
/* This file contains the error-message and diagnostic /* This file contains the error-message and diagnostic
@ -36,6 +37,7 @@ int err_occurred = 0;
extern char *symbol2str(); extern char *symbol2str();
extern char options[]; extern char options[];
extern char loptions[];
/* There are three general error-message functions: /* There are three general error-message functions:
lexerror() lexical and pre-processor error messages lexerror() lexical and pre-processor error messages
@ -48,8 +50,8 @@ extern char options[];
expression, whereas other errors use the information in the token. expression, whereas other errors use the information in the token.
*/ */
/*VARARGS1*/ /*VARARGS*/
error(va_alist) error(va_alist) /* fmt, args */
va_dcl va_dcl
{ {
va_list ap; va_list ap;
@ -61,8 +63,8 @@ error(va_alist)
va_end(ap); va_end(ap);
} }
/*VARARGS2*/ /*VARARGS*/
expr_error(va_alist) expr_error(va_alist) /* expr, fmt, args */
va_dcl va_dcl
{ {
va_list ap; va_list ap;
@ -80,8 +82,8 @@ expr_error(va_alist)
va_end(ap); va_end(ap);
} }
/*VARARGS1*/ /*VARARGS*/
warning(va_alist) warning(va_alist) /* fmt, args */
va_dcl va_dcl
{ {
va_list ap; va_list ap;
@ -93,8 +95,8 @@ warning(va_alist)
va_end(ap); va_end(ap);
} }
/*VARARGS2*/ /*VARARGS*/
expr_warning(va_alist) expr_warning(va_alist) /* expr, fmt, args */
va_dcl va_dcl
{ {
va_list ap; va_list ap;
@ -111,8 +113,8 @@ expr_warning(va_alist)
va_end(ap); va_end(ap);
} }
/*VARARGS1*/ /*VARARGS*/
lexerror(va_alist) lexerror(va_alist) /* fmt, args */
va_dcl va_dcl
{ {
va_list ap; va_list ap;
@ -125,8 +127,8 @@ lexerror(va_alist)
} }
#ifndef NOPP #ifndef NOPP
/*VARARGS1*/ /*VARARGS*/
lexwarning(va_alist) lexwarning(va_alist) /* fmt, args */
va_dcl va_dcl
{ {
va_list ap; va_list ap;
@ -139,8 +141,8 @@ lexwarning(va_alist)
} }
#endif NOPP #endif NOPP
/*VARARGS1*/ /*VARARGS*/
crash(va_alist) crash(va_alist) /* fmt, args */
va_dcl va_dcl
{ {
va_list ap; va_list ap;
@ -157,10 +159,11 @@ crash(va_alist)
#else DEBUG #else DEBUG
sys_stop(S_EXIT); sys_stop(S_EXIT);
#endif DEBUG #endif DEBUG
/* NOTREACHED */
} }
/*VARARGS1*/ /*VARARGS*/
fatal(va_alist) fatal(va_alist) /* fmt, args */
va_dcl va_dcl
{ {
va_list ap; va_list ap;

View file

@ -355,8 +355,7 @@ EVAL(expr, val, code, true_label, false_label)
store_block(tp->tp_size, tp->tp_align); store_block(tp->tp_size, tp->tp_align);
} }
else if (newcode) else if (newcode)
store_val(&(left->ex_object.ex_value), store_val(&(left->EX_VALUE), left->ex_type);
left->ex_type);
} }
break; break;
case PLUSAB: case PLUSAB:
@ -416,7 +415,7 @@ EVAL(expr, val, code, true_label, false_label)
assop(tp, oper); assop(tp, oper);
conversion(tp, left->ex_type); conversion(tp, left->ex_type);
if (compl == 0) { if (compl == 0) {
store_val(&(left->ex_object.ex_value), store_val(&(left->EX_VALUE),
left->ex_type); left->ex_type);
if (dupval) load_val(left, RVAL); if (dupval) load_val(left, RVAL);
} }
@ -968,3 +967,4 @@ load_cst(val, siz)
C_loi(siz); C_loi(siz);
} }
} }

View file

@ -74,10 +74,11 @@ struct expr {
}; };
/* some abbreviated selections */ /* some abbreviated selections */
#define VL_CLASS ex_object.ex_value.vl_class #define EX_VALUE ex_object.ex_value
#define VL_VALUE ex_object.ex_value.vl_value #define VL_CLASS EX_VALUE.vl_class
#define VL_IDF ex_object.ex_value.vl_data.vl_idf #define VL_VALUE EX_VALUE.vl_value
#define VL_LBL ex_object.ex_value.vl_data.vl_lbl #define VL_IDF EX_VALUE.vl_data.vl_idf
#define VL_LBL EX_VALUE.vl_data.vl_lbl
#define SG_VALUE ex_object.ex_string.sg_value #define SG_VALUE ex_object.ex_string.sg_value
#define SG_LEN ex_object.ex_string.sg_len #define SG_LEN ex_object.ex_string.sg_len
#define SG_DATLAB ex_object.ex_string.sg_datlab #define SG_DATLAB ex_object.ex_string.sg_datlab

View file

@ -12,6 +12,7 @@
#include "idf.h" #include "idf.h"
#include "label.h" #include "label.h"
#include "expr.h" #include "expr.h"
#include "code.h"
#include "noRoption.h" #include "noRoption.h"
extern char options[]; extern char options[];
@ -337,5 +338,7 @@ identifier(struct idf **idfp;) :
| |
TYPE_IDENTIFIER TYPE_IDENTIFIER
] ]
{*idfp = dot.tk_idf;} {
*idfp = dot.tk_idf;
}
; ;

View file

@ -74,7 +74,7 @@ eval_field(expr, code)
load_val(leftop, RVAL); load_val(leftop, RVAL);
C_and(asize); C_and(asize);
C_ior(asize); C_ior(asize);
store_val(&(leftop->ex_object.ex_value), atype); store_val(&(leftop->EX_VALUE), atype);
} }
else { /* complex case */ else { /* complex case */
tmpvar = NewLocal(pointer_size, pointer_align, tmpvar = NewLocal(pointer_size, pointer_align,
@ -144,7 +144,7 @@ eval_field(expr, code)
load_val(leftop, RVAL); load_val(leftop, RVAL);
C_and(asize); C_and(asize);
C_ior(asize); C_ior(asize);
store_val(&(leftop->ex_object.ex_value), atype); store_val(&(leftop->EX_VALUE), atype);
} }
else { else {
LoadLocal(tmpvar, pointer_size); LoadLocal(tmpvar, pointer_size);
@ -173,3 +173,4 @@ eval_field(expr, code)
} }
} }
#endif NOBITFIELD #endif NOBITFIELD

View file

@ -265,6 +265,7 @@ declare_idf(ds, dc, lvl)
warning("redeclaring reserved word %s", idf->id_text); warning("redeclaring reserved word %s", idf->id_text);
} }
#endif #endif
if (def && if (def &&
( def->df_level == lvl || ( def->df_level == lvl ||
( lvl != L_GLOBAL && def->df_level > lvl ) ( lvl != L_GLOBAL && def->df_level > lvl )

View file

@ -5,7 +5,7 @@
/* $Header$ */ /* $Header$ */
/* IDENTIFIER DESCRIPTOR */ /* IDENTIFIER DESCRIPTOR */
#include "nopp.h" #include "nopp.h"
/* Since the % operation in the calculation of the hash function /* Since the % operation in the calculation of the hash function
turns out to be expensive, it is replaced by the cheaper XOR (^). turns out to be expensive, it is replaced by the cheaper XOR (^).

View file

@ -26,6 +26,7 @@
#include "LLlex.h" #include "LLlex.h"
#include "noRoption.h" #include "noRoption.h"
#include "estack.h" #include "estack.h"
#include "code.h"
#define con_nullbyte() C_con_ucon("0", (arith)1) #define con_nullbyte() C_con_ucon("0", (arith)1)
#define aggregate_type(tp) ((tp)->tp_fund == ARRAY || (tp)->tp_fund == STRUCT) #define aggregate_type(tp) ((tp)->tp_fund == ARRAY || (tp)->tp_fund == STRUCT)
@ -47,14 +48,15 @@ initial_value(register struct type **tpp; register struct expr **expp;) :
{ if (tpp) gen_tpcheck(tpp, 0); } { if (tpp) gen_tpcheck(tpp, 0); }
[ [
assignment_expression(expp) assignment_expression(expp)
{ if ((*expp)->ex_type->tp_fund == ARRAY) {
if ((*expp)->ex_type->tp_fund == ARRAY)
array2pointer(*expp); array2pointer(*expp);
if (tpp) { if (tpp) {
gen_simple_exp(tpp, expp); gen_simple_exp(tpp, expp);
free_expression(*expp); free_expression(*expp);
*expp = 0; *expp = 0;
}
} }
}
| |
initial_value_pack(tpp, expp) initial_value_pack(tpp, expp)
] ]

View file

@ -175,7 +175,7 @@ compile(argc, argv)
#ifndef NOPP #ifndef NOPP
WorkingDir = getwdir(source); WorkingDir = getwdir(source);
#endif NOPP #endif NOPP
PushLex(); PushLex(); /* initialize lex machine */
#ifdef DEBUG #ifdef DEBUG
#ifndef NOPP #ifndef NOPP

View file

@ -40,40 +40,40 @@ do_option(text)
default: default:
fatal("illegal option: %c", *--text); fatal("illegal option: %c", *--text);
break;
case '-': case '-':
options[*text] = 1; /* flags, debug options etc. */ options[*text] = 1; /* flags, debug options etc. */
break; break;
#ifdef DATAFLOW #ifdef DATAFLOW
case 'd': case 'd':
#endif DATAFLOW #endif DATAFLOW
case 'p': /* procentry/procexit */ case 'p': /* procentry/procexit */
case 'L' : /* no fil/lin */ case 'L' : /* no fil/lin */
case 'n': /* use no registers */ case 'n': /* use no registers */
case 'w': /* no warnings will be given */ case 'w': /* no warnings will be given */
#ifndef NOROPTION #ifndef NOROPTION
case 'R': /* strict version */ case 'R': /* strict version */
#endif #endif
options[*(text-1)] = 1; options[*(text-1)] = 1;
break; break;
#ifdef NOROPTION #ifdef NOROPTION
case 'R': case 'R':
warning("-R option not implemented"); warning("-R option not implemented");
break; break;
#endif #endif
#ifdef ___XXX___ #ifdef ___XXX___
deleted, is now a debug-flag deleted, is now a debug-flag
case 'C' : /* E option + comment output */ case 'C' : /* E option + comment output */
#ifndef NOPP #ifndef NOPP
options['E'] = 1; options['E'] = 1;
warning("-C: comment is not output"); warning("-C: comment is not output");
#else NOPP #else NOPP
warning("-C option ignored"); warning("-C option ignored");
#endif NOPP #endif NOPP
break; break;
#endif ___XXX___ #endif ___XXX___
case 'D' : { /* -Dname : predefine name */ case 'D' : { /* -Dname : predefine name */
#ifndef NOPP #ifndef NOPP

View file

@ -61,7 +61,6 @@
extern arith ifval; extern arith ifval;
#endif NOPP #endif NOPP
/*VARARGS*/
extern error(); extern error();
} }
@ -121,7 +120,9 @@ external_definition
ext_decl_specifiers(&Ds) ext_decl_specifiers(&Ds)
[ [
declarator(&Dc) declarator(&Dc)
{declare_idf(&Ds, &Dc, level);} {
declare_idf(&Ds, &Dc, level);
}
[%if (Dc.dc_idf->id_def->df_type->tp_fund == FUNCTION) [%if (Dc.dc_idf->id_def->df_type->tp_fund == FUNCTION)
/* int i (1) {2, 3} /* int i (1) {2, 3}
is a function, not an old-fashioned is a function, not an old-fashioned
@ -155,6 +156,8 @@ non_function(register struct decspecs *ds; register struct declarator *dc;)
| |
{ code_declaration(dc->dc_idf, (struct expr *) 0, level, ds->ds_sc); } { code_declaration(dc->dc_idf, (struct expr *) 0, level, ds->ds_sc); }
] ]
{
}
[ [
',' ','
init_declarator(ds) init_declarator(ds)
@ -169,7 +172,6 @@ function(struct declarator *dc;)
} }
: :
{ register struct idf *idf = dc->dc_idf; { register struct idf *idf = dc->dc_idf;
init_idf(idf); init_idf(idf);
stack_level(); /* L_FORMAL1 declarations */ stack_level(); /* L_FORMAL1 declarations */
declare_params(dc); declare_params(dc);

View file

@ -31,6 +31,8 @@ extern int level;
/* 9 */ /* 9 */
statement statement
{
}
: :
%if (AHEAD != ':') %if (AHEAD != ':')
expression_statement expression_statement
@ -54,11 +56,15 @@ statement
default_statement default_statement
| |
BREAK BREAK
{code_break();} {
code_break();
}
';' ';'
| |
CONTINUE CONTINUE
{code_continue();} {
code_continue();
}
';' ';'
| |
return_statement return_statement
@ -261,6 +267,8 @@ for_statement
';' ';'
expression(&e_incr)? expression(&e_incr)?
')' ')'
{
}
statement statement
{ {
C_df_ilb(l_continue); C_df_ilb(l_continue);
@ -388,3 +396,4 @@ asm_statement
{ code_asm(asm_bts, asm_len); { code_asm(asm_bts, asm_len);
} }
; ;

View file

@ -5,8 +5,8 @@
/* $Header$ */ /* $Header$ */
/* TYPE DESCRIPTOR */ /* TYPE DESCRIPTOR */
#include "nofloat.h" #include "nofloat.h"
#include "nobitfield.h" #include "nobitfield.h"
struct type { struct type {
struct type *next; /* used only with ARRAY */ struct type *next; /* used only with ARRAY */