From 61b8c3e9ec262a3549516034e224e833c406f79b Mon Sep 17 00:00:00 2001 From: dick Date: Tue, 23 Aug 1988 12:45:11 +0000 Subject: [PATCH] more modifications due to lint --- lang/cem/cemcom/LLlex.c | 1 - lang/cem/cemcom/LLlex.h | 1 - lang/cem/cemcom/Version.c | 2 ++ lang/cem/cemcom/arith.c | 23 ++++++++++------------- lang/cem/cemcom/code.c | 16 +++++++++------- lang/cem/cemcom/conversion.c | 35 ++++++++++++++++++----------------- lang/cem/cemcom/declar.str | 3 --- lang/cem/cemcom/decspecs.c | 1 - lang/cem/cemcom/decspecs.str | 2 -- lang/cem/cemcom/dumpidf.c | 2 -- lang/cem/cemcom/ival.g | 8 ++++---- lang/cem/cemcom/main.c | 5 +++-- lang/cem/cemcom/program.g | 2 +- lang/cem/cemcom/scan.c | 20 ++++++++++---------- lang/cem/cemcom/type.c | 6 +++--- 15 files changed, 60 insertions(+), 67 deletions(-) diff --git a/lang/cem/cemcom/LLlex.c b/lang/cem/cemcom/LLlex.c index 65439c802..cf1cf871a 100644 --- a/lang/cem/cemcom/LLlex.c +++ b/lang/cem/cemcom/LLlex.c @@ -27,7 +27,6 @@ struct token dot, ahead, aside; #ifndef NOPP int ReplaceMacros = 1; /* replacing macros */ -int PreProcKeys = 0; /* return preprocessor key */ int AccDefined = 0; /* accept "defined(...)" */ int UnknownIdIsZero = 0; /* interpret unknown id as integer 0 */ int Unstacked = 0; /* an unstack is done */ diff --git a/lang/cem/cemcom/LLlex.h b/lang/cem/cemcom/LLlex.h index 3d36f5c8b..a714065a7 100644 --- a/lang/cem/cemcom/LLlex.h +++ b/lang/cem/cemcom/LLlex.h @@ -51,7 +51,6 @@ extern struct token dot, ahead, aside; #ifndef NOPP extern int ReplaceMacros; /* "LLlex.c" */ -extern int PreProcKeys; /* "LLlex.c" */ extern int AccDefined; /* "LLlex.c" */ extern int Unstacked; /* "LLlex.c" */ extern int UnknownIdIsZero; /* "LLlex.c" */ diff --git a/lang/cem/cemcom/Version.c b/lang/cem/cemcom/Version.c index da755b0d9..c10d537ea 100644 --- a/lang/cem/cemcom/Version.c +++ b/lang/cem/cemcom/Version.c @@ -3,4 +3,6 @@ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ +#ifndef lint static char Version[] = "ACK CEM compiler Version 3.1"; +#endif lint diff --git a/lang/cem/cemcom/arith.c b/lang/cem/cemcom/arith.c index ea9dc3207..3d87fbd7b 100644 --- a/lang/cem/cemcom/arith.c +++ b/lang/cem/cemcom/arith.c @@ -28,7 +28,6 @@ extern char *symbol2str(); extern char options[]; -int arithbalance(e1p, oper, e2p) /* RM 6.6 */ register struct expr **e1p, **e2p; int oper; @@ -43,14 +42,16 @@ arithbalance(e1p, oper, e2p) /* RM 6.6 */ /* Now t1 and t2 are either INT or LONG or DOUBLE */ #ifndef NOFLOAT - if (t1 == DOUBLE && t2 != DOUBLE) - t2 = int2float(e2p, double_type); - else - if (t2 == DOUBLE && t1 != DOUBLE) - t1 = int2float(e1p, double_type); - else - if (t1 == DOUBLE) - return DOUBLE; + if (t1 == DOUBLE) { + if (t2 != DOUBLE) + int2float(e2p, double_type); + return; + } + if (t2 == DOUBLE) { + if (t1 != DOUBLE) + int2float(e1p, double_type); + return; + } #endif NOFLOAT /* Now they are INT or LONG */ @@ -70,8 +71,6 @@ arithbalance(e1p, oper, e2p) /* RM 6.6 */ else if (!u1 && u2) t1 = int2int(e1p, (t2 == LONG) ? ulong_type : uint_type); - - return t1; } relbalance(e1p, oper, e2p) @@ -262,7 +261,6 @@ int2int(expp, tp) } #ifndef NOFLOAT -int int2float(expp, tp) register struct expr **expp; struct type *tp; @@ -273,7 +271,6 @@ int2float(expp, tp) fp_used = 1; *expp = arith2arith(tp, INT2FLOAT, *expp); - return (*expp)->ex_type->tp_fund; } float2int(expp, tp) diff --git a/lang/cem/cemcom/code.c b/lang/cem/cemcom/code.c index 8640c34d4..1fa3647d2 100644 --- a/lang/cem/cemcom/code.c +++ b/lang/cem/cemcom/code.c @@ -460,14 +460,16 @@ loc_init(expr, id) } } else { /* not embraced */ - struct value vl; - ch7cast(&expr, '=', tp); /* may modify expr */ - EVAL(expr, RVAL, TRUE, NO_LABEL, NO_LABEL); - vl.vl_class = Name; - vl.vl_data.vl_idf = id; - vl.vl_value = (arith)0; - store_val(&vl, tp); + { + struct value vl; + + EVAL(expr, RVAL, TRUE, NO_LABEL, NO_LABEL); + vl.vl_class = Name; + vl.vl_data.vl_idf = id; + vl.vl_value = (arith)0; + store_val(&vl, tp); + } free_expression(expr); } } diff --git a/lang/cem/cemcom/conversion.c b/lang/cem/cemcom/conversion.c index 112eed850..3f8938ad4 100644 --- a/lang/cem/cemcom/conversion.c +++ b/lang/cem/cemcom/conversion.c @@ -20,28 +20,29 @@ /* conversion() generates the EM code for a conversion between the types char, short, int, long, float, double and pointer. - In case of integral type, the notion signed / unsigned is - taken into account. + There are three conversion types: signed, unsigned and floating. The EM code to obtain this conversion looks like: LOC sizeof(from_type) LOC sizeof(to_type) C?? */ +static int convtype(); + conversion(from_type, to_type) register struct type *from_type, *to_type; { register arith from_size = from_type->tp_size; register arith to_size = to_type->tp_size; - int from_fund = fundamental(from_type); - int to_fund = fundamental(to_type); + int from_cnvtype = convtype(from_type); + int to_cnvtype = convtype(to_type); if ((int)to_size < (int)word_size) to_size = word_size; - if ((int)from_size == (int)to_size && from_fund == to_fund) + if ((int)from_size == (int)to_size && from_cnvtype == to_cnvtype) return; - switch (from_fund) { + switch (from_cnvtype) { case T_SIGNED: - switch (to_fund) { + switch (to_cnvtype) { case T_SIGNED: C_loc(from_size); C_loc(to_size); @@ -59,7 +60,7 @@ conversion(from_type, to_type) } C_loc(from_size); C_loc(to_size); - if (to_fund == T_UNSIGNED) C_ciu(); + if (to_cnvtype == T_UNSIGNED) C_ciu(); else C_cif(); break; } @@ -68,7 +69,7 @@ conversion(from_type, to_type) if ((int)from_size < (int)word_size) from_size = word_size; C_loc(from_size); C_loc(to_size); - switch (to_fund) { + switch (to_cnvtype) { case T_SIGNED: C_cui(); break; @@ -86,7 +87,7 @@ conversion(from_type, to_type) case T_FLOATING: C_loc(from_size); C_loc(to_size); - switch (to_fund) { + switch (to_cnvtype) { case T_SIGNED: C_cfi(); break; @@ -104,12 +105,12 @@ conversion(from_type, to_type) } if ((int)(to_type->tp_size) < (int)word_size #ifndef NOFLOAT - && to_fund != T_FLOATING + && to_cnvtype != T_FLOATING #endif NOFLOAT ) { extern long full_mask[]; - if (to_fund == T_SIGNED) { + if (to_cnvtype == T_SIGNED) { C_loc(to_type->tp_size); C_loc(word_size); C_cii(); @@ -121,11 +122,11 @@ conversion(from_type, to_type) } } -/* fundamental() returns in which category a given type falls: +/* convtype() returns in which category a given type falls: signed, unsigned or floating */ -int -fundamental(tp)/* bad name ???*/ +static int +convtype(tp)/* bad name ???*/ register struct type *tp; { switch (tp->tp_fund) { @@ -141,8 +142,8 @@ fundamental(tp)/* bad name ???*/ case DOUBLE: return T_FLOATING; #endif NOFLOAT - case POINTER: /* pointer : signed / unsigned ??? */ - return T_SIGNED; + case POINTER: + return T_UNSIGNED; } return 0; } diff --git a/lang/cem/cemcom/declar.str b/lang/cem/cemcom/declar.str index e5aefd5f5..2e0da64ab 100644 --- a/lang/cem/cemcom/declar.str +++ b/lang/cem/cemcom/declar.str @@ -17,9 +17,6 @@ struct declarator { struct formal *dc_formal; /* params for function */ }; -/* ALLOCDEF "declarator" 50 */ - - struct formal { /* list of formals */ struct formal *next; struct idf *fm_idf; diff --git a/lang/cem/cemcom/decspecs.c b/lang/cem/cemcom/decspecs.c index a452d5d1c..530494bdf 100644 --- a/lang/cem/cemcom/decspecs.c +++ b/lang/cem/cemcom/decspecs.c @@ -42,7 +42,6 @@ do_decspecs(ds) if (level == L_FORMAL2) { if (ds->ds_sc_given && ds->ds_sc != REGISTER){ - extern char *symbol2str(); error("%s formal illegal", symbol2str(ds->ds_sc)); ds->ds_sc = FORMAL; } diff --git a/lang/cem/cemcom/decspecs.str b/lang/cem/cemcom/decspecs.str index 5bca322db..03464f448 100644 --- a/lang/cem/cemcom/decspecs.str +++ b/lang/cem/cemcom/decspecs.str @@ -14,6 +14,4 @@ struct decspecs { int ds_unsigned; /* 0 or 1 */ }; -/* ALLOCDEF "decspecs" 50 */ - extern struct decspecs null_decspecs; diff --git a/lang/cem/cemcom/dumpidf.c b/lang/cem/cemcom/dumpidf.c index 169a00536..639046875 100644 --- a/lang/cem/cemcom/dumpidf.c +++ b/lang/cem/cemcom/dumpidf.c @@ -319,8 +319,6 @@ print_expr(msg, expr) p1_expr(lvl, expr) register struct expr *expr; { - extern char *type2str(), *symbol2str(); - p1_indent(lvl); if (!expr) { print("NILEXPR\n"); diff --git a/lang/cem/cemcom/ival.g b/lang/cem/cemcom/ival.g index 693188b6d..34afa9672 100644 --- a/lang/cem/cemcom/ival.g +++ b/lang/cem/cemcom/ival.g @@ -63,13 +63,13 @@ initial_value(register struct type **tpp; register struct expr **expp;) : ; initial_value_pack(struct type **tpp; struct expr **expp;) - { static int level; } + { static int pack_level; } : '{' - { if (level == 0) gen_error = 0; level++; } + { if (pack_level == 0) gen_error = 0; pack_level++; } initial_value_list(tpp, expp) - { level--; - if (! level) { + { pack_level--; + if (!pack_level) { while (p_stack) { struct e_stack *p = p_stack->next; diff --git a/lang/cem/cemcom/main.c b/lang/cem/cemcom/main.c index 275054336..2336572a9 100644 --- a/lang/cem/cemcom/main.c +++ b/lang/cem/cemcom/main.c @@ -371,12 +371,13 @@ preprocess() #endif NOPP #endif DEBUG -No_Mem() +No_Mem() /* called by alloc package */ { fatal("out of memory"); } -C_failed() +C_failed() /* called by EM_code module */ { fatal("write failed"); } + diff --git a/lang/cem/cemcom/program.g b/lang/cem/cemcom/program.g index 3fb087ab5..afd33d9e1 100644 --- a/lang/cem/cemcom/program.g +++ b/lang/cem/cemcom/program.g @@ -168,7 +168,7 @@ non_function(register struct decspecs *ds; register struct declarator *dc;) /* 10.1 */ function(struct declarator *dc;) { - arith fbytes, nbytes; + arith fbytes; } : { register struct idf *idf = dc->dc_idf; diff --git a/lang/cem/cemcom/scan.c b/lang/cem/cemcom/scan.c index b23a0e02b..3f1be6d91 100644 --- a/lang/cem/cemcom/scan.c +++ b/lang/cem/cemcom/scan.c @@ -80,9 +80,9 @@ getactuals(idef) } PRIVATE -copyact(ch1, ch2, level) +copyact(ch1, ch2, lvl) char ch1, ch2; - int level; + int lvl; { /* copyact() is taken from Ceriel Jacobs' LLgen, with permission. Its task is to build a list of actuals @@ -90,16 +90,16 @@ copyact(ch1, ch2, level) which the parameters are separated by ',' if there are more than 1. The balancing of '(',')' and '[',']' and '{','}' is taken care of by calling this function - recursively. At each level, copyact() reads the input, + recursively. At each level lvl, copyact() reads the input, upto the corresponding closing bracket. Opening bracket is ch1, closing bracket is ch2. If - level != 0, copy opening and closing parameters too. + lvl != 0, copy opening and closing parameters too. */ register int ch; /* Current char */ register int match; /* used to read strings */ - if (level) { + if (lvl) { copy(ch1); } @@ -107,7 +107,7 @@ copyact(ch1, ch2, level) LoadChar(ch); if (ch == ch2) { - if (level) { + if (lvl) { copy(ch); } return; @@ -124,7 +124,7 @@ copyact(ch1, ch2, level) #endif __MATCHING_PAR__ case '(': - copyact('(', ')', level+1); + copyact('(', ')', lvl+1); break; #ifdef __MATCHING_PAR__ @@ -133,11 +133,11 @@ copyact(ch1, ch2, level) #define declare(v, t) t v declare(v, union{int i, j; float r;}); */ - copyact('{', '}', level+1); + copyact('{', '}', lvl+1); break; case '[': - copyact('[', ']', level+1); + copyact('[', ']', lvl+1); break; #endif __MATCHING_PAR__ @@ -176,7 +176,7 @@ copyact(ch1, ch2, level) break; case ',': - if (!level) { + if (!lvl) { /* next parameter encountered */ copy(EOS); diff --git a/lang/cem/cemcom/type.c b/lang/cem/cemcom/type.c index 5d12d3f41..8482a820e 100644 --- a/lang/cem/cemcom/type.c +++ b/lang/cem/cemcom/type.c @@ -212,13 +212,13 @@ align(pos, al) } struct type * -standard_type(fund, sign, align, size) - int align; arith size; +standard_type(fund, sign, algn, size) + int algn; arith size; { register struct type *tp = create_type(fund); tp->tp_unsigned = sign; - tp->tp_align = align; + tp->tp_align = algn; tp->tp_size = size; return tp; -- 2.34.1