Browse Source

adapted to integration into cemcom.ansi

dick 33 years ago
parent
commit
9507d33945

+ 1 - 1
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

+ 8 - 8
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

+ 1 - 1
lang/cem/cemcom/code.c

@@ -9,7 +9,7 @@
 #ifndef	LINT
 #include	<em.h>
 #else
-#include	"em_lint.h"
+#include	"l_em.h"
 #include	"l_lint.h"
 #endif	LINT
 #include	"botch_free.h"

+ 1 - 1
lang/cem/cemcom/error.c

@@ -11,7 +11,7 @@
 #ifndef	LINT
 #include	<em.h>
 #else
-#include	"em_lint.h"
+#include	"l_em.h"
 #endif	LINT
 
 #include	"nopp.h"

+ 3 - 18
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

+ 1 - 1
lang/cem/cemcom/ival.g

@@ -11,7 +11,7 @@
 #ifndef	LINT
 #include	<em.h>
 #else
-#include	"em_lint.h"
+#include	"l_em.h"
 #include	"l_lint.h"
 #endif	LINT
 #include	"debug.h"

+ 75 - 0
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)
+

+ 3 - 1
lang/cem/cemcom/l_ev_ord.c

@@ -12,6 +12,9 @@
 #include	<alloc.h>	/* for st_free */
 #include	"interface.h"
 #include	"assert.h"
+#ifdef ANSI
+#include	<flt_arith.h>
+#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"
 

+ 3 - 1
lang/cem/cemcom/l_lint.c

@@ -13,6 +13,9 @@
 #include	"debug.h"
 #include	"interface.h"
 #include	"assert.h"
+#ifdef ANSI
+#include	<flt_arith.h>
+#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"

+ 29 - 1
lang/cem/cemcom/l_misc.c

@@ -11,6 +11,9 @@
 
 #include	<alloc.h>	/* for st_free */
 #include	"interface.h"
+#ifdef ANSI
+#include	<flt_arith.h>
+#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;
 {

+ 22 - 1
lang/cem/cemcom/l_outdef.c

@@ -11,9 +11,14 @@
 
 #include	<alloc.h>
 #include	"interface.h"
+#ifdef ANSI
+#include	<flt_arith.h>
+#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);

+ 5 - 1
lang/cem/cemcom/l_states.c

@@ -13,6 +13,9 @@
 #include	"interface.h"
 #include	"assert.h"
 #include	"debug.h"
+#ifdef ANSI
+#include	<flt_arith.h>
+#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;
 

+ 1 - 4
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
 	}
 	[

+ 1 - 1
lang/cem/cemcom/stack.c

@@ -11,7 +11,7 @@
 #ifndef	LINT
 #include	<em.h>
 #else
-#include	"em_lint.h"
+#include	"l_em.h"
 #endif	LINT
 #include	"debug.h"
 #include	"botch_free.h"

+ 1 - 1
lang/cem/cemcom/statement.g

@@ -10,7 +10,7 @@
 #ifndef	LINT
 #include	<em.h>
 #else
-#include	"em_lint.h"
+#include	"l_em.h"
 #include	"l_lint.h"
 #endif	LINT
 

+ 1 - 1
lang/cem/cemcom/switch.c

@@ -10,7 +10,7 @@
 #ifndef	LINT
 #include	<em.h>
 #else
-#include	"em_lint.h"
+#include	"l_em.h"
 #endif	LINT
 #include	"debug.h"
 #include	"botch_free.h"

+ 1 - 1
lang/cem/cemcom/util.c

@@ -15,7 +15,7 @@
 #ifndef	LINT
 #include	<em.h>
 #else
-#include	"em_lint.h"
+#include	"l_em.h"
 #endif	LINT
 #include	<em_arith.h>
 #include	<em_reg.h>