From 65bf3591a7443797a8c8486ddb0488adb5dbb131 Mon Sep 17 00:00:00 2001 From: dick Date: Thu, 6 Dec 1990 14:56:42 +0000 Subject: [PATCH] adapted to integration into cemcom.ansi --- lang/cem/cemcom/.distr | 2 +- lang/cem/cemcom/Makefile | 16 ++++---- lang/cem/cemcom/code.c | 2 +- lang/cem/cemcom/error.c | 2 +- lang/cem/cemcom/idf.c | 21 ++--------- lang/cem/cemcom/ival.g | 2 +- lang/cem/cemcom/l_em.h | 75 +++++++++++++++++++++++++++++++++++++ lang/cem/cemcom/l_ev_ord.c | 4 +- lang/cem/cemcom/l_lint.c | 4 +- lang/cem/cemcom/l_misc.c | 30 ++++++++++++++- lang/cem/cemcom/l_outdef.c | 23 +++++++++++- lang/cem/cemcom/l_states.c | 6 ++- lang/cem/cemcom/program.g | 5 +-- lang/cem/cemcom/stack.c | 2 +- lang/cem/cemcom/statement.g | 2 +- lang/cem/cemcom/switch.c | 2 +- lang/cem/cemcom/util.c | 2 +- 17 files changed, 157 insertions(+), 43 deletions(-) create mode 100644 lang/cem/cemcom/l_em.h diff --git a/lang/cem/cemcom/.distr b/lang/cem/cemcom/.distr index 013f3ab77..cd6f503d5 100644 --- a/lang/cem/cemcom/.distr +++ b/lang/cem/cemcom/.distr @@ -36,7 +36,6 @@ decspecs.str def.str domacro.c dumpidf.c -em_lint.h error.c estack.str eval.c @@ -57,6 +56,7 @@ l_brace.str l_class.h l_comment.h l_comment.c +l_em.h l_ev_ord.c l_lint.c l_lint.h diff --git a/lang/cem/cemcom/Makefile b/lang/cem/cemcom/Makefile index b9421a236..a85a9fa63 100644 --- a/lang/cem/cemcom/Makefile +++ b/lang/cem/cemcom/Makefile @@ -121,7 +121,7 @@ GHSRC = botch_free.h dataflow.h debug.h density.h errout.h \ HSRC = LLlex.h align.h arith.h assert.h atw.h class.h \ input.h interface.h label.h level.h mes.h sizes.h specials.h \ - file_info.h tokenname.h em_lint.h l_lint.h + file_info.h tokenname.h l_em.h l_lint.h HFILES = $(HSRC) $(GHSRC) $(GHSTRSRC) @@ -466,7 +466,7 @@ code.o: debug.h code.o: declar.h code.o: decspecs.h code.o: def.h -code.o: em_lint.h +code.o: l_em.h code.o: expr.h code.o: file_info.h code.o: idf.h @@ -508,7 +508,7 @@ error.o: LLlex.h error.o: arith.h error.o: debug.h error.o: def.h -error.o: em_lint.h +error.o: l_em.h error.o: errout.h error.o: expr.h error.o: file_info.h @@ -660,7 +660,7 @@ stack.o: arith.h stack.o: botch_free.h stack.o: debug.h stack.o: def.h -stack.o: em_lint.h +stack.o: l_em.h stack.o: idf.h stack.o: level.h stack.o: lint.h @@ -746,7 +746,7 @@ switch.o: botch_free.h switch.o: code.h switch.o: debug.h switch.o: density.h -switch.o: em_lint.h +switch.o: l_em.h switch.o: expr.h switch.o: idf.h switch.o: label.h @@ -771,7 +771,7 @@ conversion.o: type.h util.o: Lpars.h util.o: align.h util.o: def.h -util.o: em_lint.h +util.o: l_em.h util.o: lint.h util.o: nocross.h util.o: nofloat.h @@ -948,7 +948,7 @@ statement.o: botch_free.h statement.o: code.h statement.o: debug.h statement.o: def.h -statement.o: em_lint.h +statement.o: l_em.h statement.o: expr.h statement.o: file_info.h statement.o: idf.h @@ -1000,7 +1000,7 @@ ival.o: arith.h ival.o: assert.h ival.o: debug.h ival.o: def.h -ival.o: em_lint.h +ival.o: l_em.h ival.o: estack.h ival.o: expr.h ival.o: field.h diff --git a/lang/cem/cemcom/code.c b/lang/cem/cemcom/code.c index 20ffff5ed..6f03dd3ed 100644 --- a/lang/cem/cemcom/code.c +++ b/lang/cem/cemcom/code.c @@ -9,7 +9,7 @@ #ifndef LINT #include #else -#include "em_lint.h" +#include "l_em.h" #include "l_lint.h" #endif LINT #include "botch_free.h" diff --git a/lang/cem/cemcom/error.c b/lang/cem/cemcom/error.c index f2a27d9d5..756fc2144 100644 --- a/lang/cem/cemcom/error.c +++ b/lang/cem/cemcom/error.c @@ -11,7 +11,7 @@ #ifndef LINT #include #else -#include "em_lint.h" +#include "l_em.h" #endif LINT #include "nopp.h" diff --git a/lang/cem/cemcom/idf.c b/lang/cem/cemcom/idf.c index 64d4abbeb..7dbf1756e 100644 --- a/lang/cem/cemcom/idf.c +++ b/lang/cem/cemcom/idf.c @@ -273,23 +273,7 @@ declare_idf(ds, dc, lvl) #endif #ifdef LINT - if ( def && def->df_level < lvl - && !( lvl == L_FORMAL2 - || def->df_level == L_UNIVERSAL - || sc == GLOBAL - || sc == EXTERN - ) - ) { - /* there is already a definition for this non-extern name - on a more global level - */ - warning("%s is already defined as a %s", - idf->id_text, - def->df_level == L_GLOBAL ? "global" : - def->df_level == L_FORMAL2 ? "formal" : - "more global local" - ); - } + check_hiding(idf, lvl, sc); /* of some idf by this idf */ #endif LINT if (def && @@ -490,7 +474,8 @@ global_redecl(idf, new_sc, tp) error("cannot redeclare %s to static", idf->id_text); else { -#ifdef LINT /* warn unconditionally */ +#ifdef LINT + /* warn unconditionally */ warning("%s redeclared to static", idf->id_text); #else LINT diff --git a/lang/cem/cemcom/ival.g b/lang/cem/cemcom/ival.g index a3e30b1ab..f13b89a46 100644 --- a/lang/cem/cemcom/ival.g +++ b/lang/cem/cemcom/ival.g @@ -11,7 +11,7 @@ #ifndef LINT #include #else -#include "em_lint.h" +#include "l_em.h" #include "l_lint.h" #endif LINT #include "debug.h" diff --git a/lang/cem/cemcom/l_em.h b/lang/cem/cemcom/l_em.h new file mode 100644 index 000000000..f59e21876 --- /dev/null +++ b/lang/cem/cemcom/l_em.h @@ -0,0 +1,75 @@ +/* + * (c) copyright 1990 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ + +/* + * This file can be considered the em_code.h file of lint. + * Those code generating functions that are used by cem and that have not + * been defined away by #ifdef LINT, are defined away here. Note that this a + * fairly random collection. E.g. it does not include C_open(), since the + * standard C-open() C_close() sequence is protected by #ifdef LINT, but it + * does include C_close() since the latter is also called in other places, + * to terminate the compilation process. + */ + +#define store_block(sz, al) +#define load_block(sz, al) + +#define C_asp(c) +#define C_bra(b) +#define C_cal(p) +#define C_csa(w) +#define C_csb(w) +#define C_fil_dlb(g,o) +#define C_lae_dlb(g,o) +#define C_lal(c) +#define C_lin(c) +#define C_loi(c) +#define C_lol(c) +#define C_sdl(c) +#define C_sti(c) +#define C_stl(c) + +#define C_busy() 0 +#define C_close() + +#define C_df_dlb(l) +#define C_df_dnam(s) +#define C_df_ilb(l) + +#define C_pro_narg(s) +#define C_end(l) + +#define C_exa_dnam(s) +#define C_ina_dnam(s) +#define C_ina_dlb(l) +#define C_exp(s) +#define C_inp(s) + +#define C_bss_cst(n,w,i) + +#define C_con_cst(v) +#define C_con_icon(v,s) +#define C_con_ucon(v,s) +#define C_con_fcon(v,s) +#define C_con_scon(v,s) +#define C_con_dnam(v,s) +#define C_con_dlb(v,s) +#define C_con_pnam(v) + +#define C_rom_cst(v) +#define C_rom_icon(v,s) +#define C_rom_scon(v,s) +#define C_rom_ilb(v) + +#define C_ldl(l) + +#define C_mes_begin(ms) +#define C_mes_end() + +#define C_ms_gto() +#define C_ms_par(b) +#define C_ms_reg(o,s,t,c) + diff --git a/lang/cem/cemcom/l_ev_ord.c b/lang/cem/cemcom/l_ev_ord.c index c0cfe4c49..be44675c8 100644 --- a/lang/cem/cemcom/l_ev_ord.c +++ b/lang/cem/cemcom/l_ev_ord.c @@ -12,6 +12,9 @@ #include /* for st_free */ #include "interface.h" #include "assert.h" +#ifdef ANSI +#include +#endif ANSI #include "arith.h" /* definition arith */ #include "label.h" /* definition label */ #include "expr.h" @@ -23,7 +26,6 @@ #include "stack.h" #include "type.h" #include "level.h" -#include "nofloat.h" #include "l_lint.h" #include "l_state.h" diff --git a/lang/cem/cemcom/l_lint.c b/lang/cem/cemcom/l_lint.c index cc0c8557e..73adf197f 100644 --- a/lang/cem/cemcom/l_lint.c +++ b/lang/cem/cemcom/l_lint.c @@ -13,6 +13,9 @@ #include "debug.h" #include "interface.h" #include "assert.h" +#ifdef ANSI +#include +#endif ANSI #include "arith.h" /* definition arith */ #include "label.h" /* definition label */ #include "expr.h" @@ -24,7 +27,6 @@ #include "stack.h" #include "type.h" #include "level.h" -#include "nofloat.h" #include "l_lint.h" #include "l_state.h" #include "l_outdef.h" diff --git a/lang/cem/cemcom/l_misc.c b/lang/cem/cemcom/l_misc.c index 22947d27b..d0213ca1b 100644 --- a/lang/cem/cemcom/l_misc.c +++ b/lang/cem/cemcom/l_misc.c @@ -11,6 +11,9 @@ #include /* for st_free */ #include "interface.h" +#ifdef ANSI +#include +#endif ANSI #include "arith.h" /* definition arith */ #include "label.h" /* definition label */ #include "expr.h" @@ -22,7 +25,6 @@ #include "stack.h" #include "type.h" #include "level.h" -#include "nofloat.h" #include "l_state.h" extern char *symbol2str(); @@ -32,6 +34,32 @@ PRIVATE lint_enum_arith(); PRIVATE lint_conversion(); PRIVATE int numsize(); +check_hiding(idf, lvl, sc) + struct idf *idf; + int lvl; + int sc; +{ + /* Checks if there is already a definition for this non-extern + name on a more global level. + */ + struct def *def = idf->id_def; + + if ( def && def->df_level < lvl + && ! ( lvl == L_FORMAL2 + || def->df_level == L_UNIVERSAL + || sc == GLOBAL + || sc == EXTERN + ) + ) { + warning("%s is already defined as a %s", + idf->id_text, + def->df_level == L_GLOBAL ? "global" : + def->df_level == L_FORMAL2 ? "formal" : + "more global local" + ); + } +} + lint_new_oper(expr) struct expr *expr; { diff --git a/lang/cem/cemcom/l_outdef.c b/lang/cem/cemcom/l_outdef.c index 273e7e765..fd3a31aef 100644 --- a/lang/cem/cemcom/l_outdef.c +++ b/lang/cem/cemcom/l_outdef.c @@ -11,9 +11,14 @@ #include #include "interface.h" +#ifdef ANSI +#include +#endif ANSI #include "arith.h" #include "assert.h" #include "type.h" +#include "declar.h" +#include "decspecs.h" #include "LLlex.h" #include "Lpars.h" #include "stack.h" @@ -45,7 +50,6 @@ PRIVATE outargs(); PRIVATE outarg(); PRIVATE outargstring(); PRIVATE outargtype(); -PRIVATE implicit_func_decl(); PRIVATE fill_arg(); lint_declare_idf(idf, sc) @@ -68,6 +72,19 @@ lint_declare_idf(idf, sc) } } +lint_non_function_decl(ds, dc) + struct decspecs *ds; + struct declarator *dc; +{ + register struct def *def = dc->dc_idf->id_def; + register int is_function = def->df_type->tp_fund == FUNCTION; + + if (is_function) + def2decl(ds->ds_sc); + if (def->df_sc != TYPEDEF) + outdef(); +} + lint_ext_def(idf, sc) struct idf *idf; { @@ -466,6 +483,7 @@ outargtype(tp) } } +#ifdef IMPLICIT PRIVATE implicit_func_decl(idf, file, line) struct idf *idf; @@ -483,6 +501,7 @@ implicit_func_decl(idf, file, line) output_def(&od); /* The other fields are not used for this class. */ } +#endif IMPLICIT fill_outcall(ex, used) struct expr *ex; @@ -491,10 +510,12 @@ fill_outcall(ex, used) register struct idf *idf = ex->OP_LEFT->VL_IDF; register struct def *def = idf->id_def; +#ifdef IMPLICIT if (def->df_sc == IMPLICIT && !idf->id_def->df_used) { /* IFDC, first time */ implicit_func_decl(idf, ex->ex_file, ex->ex_line); } +#endif IMPLICIT OutCall.od_type = def->df_type->tp_up; OutCall.od_statnr = (def->df_sc == STATIC ? stat_number : 0); diff --git a/lang/cem/cemcom/l_states.c b/lang/cem/cemcom/l_states.c index 58adbf7ea..b7f87fb9c 100644 --- a/lang/cem/cemcom/l_states.c +++ b/lang/cem/cemcom/l_states.c @@ -13,6 +13,9 @@ #include "interface.h" #include "assert.h" #include "debug.h" +#ifdef ANSI +#include +#endif ANSI #include "arith.h" #include "label.h" #include "expr.h" @@ -24,7 +27,6 @@ #include "stack.h" #include "type.h" #include "level.h" -#include "nofloat.h" #include "l_lint.h" #include "l_brace.h" #include "l_state.h" @@ -201,7 +203,9 @@ lint_1_global(idf, def) case STATIC: case EXTERN: case GLOBAL: +#ifdef IMPLICIT case IMPLICIT: +#endif IMPLICIT if (fund == ERRONEOUS) break; diff --git a/lang/cem/cemcom/program.g b/lang/cem/cemcom/program.g index ac9f4e031..66c2cade6 100644 --- a/lang/cem/cemcom/program.g +++ b/lang/cem/cemcom/program.g @@ -161,10 +161,7 @@ non_function(register struct decspecs *ds; register struct declarator *dc;) ] { #ifdef LINT - if (dc->dc_idf->id_def->df_type->tp_fund == FUNCTION) - def2decl(ds->ds_sc); - if (dc->dc_idf->id_def->df_sc != TYPEDEF) - outdef(); + lint_non_function_decl(ds, dc); #endif LINT } [ diff --git a/lang/cem/cemcom/stack.c b/lang/cem/cemcom/stack.c index 41a233a18..c09a670aa 100644 --- a/lang/cem/cemcom/stack.c +++ b/lang/cem/cemcom/stack.c @@ -11,7 +11,7 @@ #ifndef LINT #include #else -#include "em_lint.h" +#include "l_em.h" #endif LINT #include "debug.h" #include "botch_free.h" diff --git a/lang/cem/cemcom/statement.g b/lang/cem/cemcom/statement.g index 9469f2cb1..5016f855c 100644 --- a/lang/cem/cemcom/statement.g +++ b/lang/cem/cemcom/statement.g @@ -10,7 +10,7 @@ #ifndef LINT #include #else -#include "em_lint.h" +#include "l_em.h" #include "l_lint.h" #endif LINT diff --git a/lang/cem/cemcom/switch.c b/lang/cem/cemcom/switch.c index 396fa4dd7..27ea92aca 100644 --- a/lang/cem/cemcom/switch.c +++ b/lang/cem/cemcom/switch.c @@ -10,7 +10,7 @@ #ifndef LINT #include #else -#include "em_lint.h" +#include "l_em.h" #endif LINT #include "debug.h" #include "botch_free.h" diff --git a/lang/cem/cemcom/util.c b/lang/cem/cemcom/util.c index 2566e059b..5e859a457 100644 --- a/lang/cem/cemcom/util.c +++ b/lang/cem/cemcom/util.c @@ -15,7 +15,7 @@ #ifndef LINT #include #else -#include "em_lint.h" +#include "l_em.h" #endif LINT #include #include -- 2.34.1