adapted to integration into cemcom.ansi

This commit is contained in:
dick 1990-12-06 14:56:42 +00:00
parent c5c6267b1d
commit 65bf3591a7
17 changed files with 157 additions and 43 deletions

View file

@ -36,7 +36,6 @@ decspecs.str
def.str def.str
domacro.c domacro.c
dumpidf.c dumpidf.c
em_lint.h
error.c error.c
estack.str estack.str
eval.c eval.c
@ -57,6 +56,7 @@ l_brace.str
l_class.h l_class.h
l_comment.h l_comment.h
l_comment.c l_comment.c
l_em.h
l_ev_ord.c l_ev_ord.c
l_lint.c l_lint.c
l_lint.h l_lint.h

View file

@ -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 \ 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 \ 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) HFILES = $(HSRC) $(GHSRC) $(GHSTRSRC)
@ -466,7 +466,7 @@ code.o: debug.h
code.o: declar.h code.o: declar.h
code.o: decspecs.h code.o: decspecs.h
code.o: def.h code.o: def.h
code.o: em_lint.h code.o: l_em.h
code.o: expr.h code.o: expr.h
code.o: file_info.h code.o: file_info.h
code.o: idf.h code.o: idf.h
@ -508,7 +508,7 @@ error.o: LLlex.h
error.o: arith.h error.o: arith.h
error.o: debug.h error.o: debug.h
error.o: def.h error.o: def.h
error.o: em_lint.h error.o: l_em.h
error.o: errout.h error.o: errout.h
error.o: expr.h error.o: expr.h
error.o: file_info.h error.o: file_info.h
@ -660,7 +660,7 @@ stack.o: arith.h
stack.o: botch_free.h stack.o: botch_free.h
stack.o: debug.h stack.o: debug.h
stack.o: def.h stack.o: def.h
stack.o: em_lint.h stack.o: l_em.h
stack.o: idf.h stack.o: idf.h
stack.o: level.h stack.o: level.h
stack.o: lint.h stack.o: lint.h
@ -746,7 +746,7 @@ switch.o: botch_free.h
switch.o: code.h switch.o: code.h
switch.o: debug.h switch.o: debug.h
switch.o: density.h switch.o: density.h
switch.o: em_lint.h switch.o: l_em.h
switch.o: expr.h switch.o: expr.h
switch.o: idf.h switch.o: idf.h
switch.o: label.h switch.o: label.h
@ -771,7 +771,7 @@ conversion.o: type.h
util.o: Lpars.h util.o: Lpars.h
util.o: align.h util.o: align.h
util.o: def.h util.o: def.h
util.o: em_lint.h util.o: l_em.h
util.o: lint.h util.o: lint.h
util.o: nocross.h util.o: nocross.h
util.o: nofloat.h util.o: nofloat.h
@ -948,7 +948,7 @@ statement.o: botch_free.h
statement.o: code.h statement.o: code.h
statement.o: debug.h statement.o: debug.h
statement.o: def.h statement.o: def.h
statement.o: em_lint.h statement.o: l_em.h
statement.o: expr.h statement.o: expr.h
statement.o: file_info.h statement.o: file_info.h
statement.o: idf.h statement.o: idf.h
@ -1000,7 +1000,7 @@ ival.o: arith.h
ival.o: assert.h ival.o: assert.h
ival.o: debug.h ival.o: debug.h
ival.o: def.h ival.o: def.h
ival.o: em_lint.h ival.o: l_em.h
ival.o: estack.h ival.o: estack.h
ival.o: expr.h ival.o: expr.h
ival.o: field.h ival.o: field.h

View file

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

View file

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

View file

@ -273,23 +273,7 @@ declare_idf(ds, dc, lvl)
#endif #endif
#ifdef LINT #ifdef LINT
if ( def && def->df_level < lvl check_hiding(idf, lvl, sc); /* of some idf by this idf */
&& !( 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"
);
}
#endif LINT #endif LINT
if (def && if (def &&
@ -490,7 +474,8 @@ global_redecl(idf, new_sc, tp)
error("cannot redeclare %s to static", error("cannot redeclare %s to static",
idf->id_text); idf->id_text);
else { else {
#ifdef LINT /* warn unconditionally */ #ifdef LINT
/* warn unconditionally */
warning("%s redeclared to static", warning("%s redeclared to static",
idf->id_text); idf->id_text);
#else LINT #else LINT

View file

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

75
lang/cem/cemcom/l_em.h Normal file
View file

@ -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)

View file

@ -12,6 +12,9 @@
#include <alloc.h> /* for st_free */ #include <alloc.h> /* for st_free */
#include "interface.h" #include "interface.h"
#include "assert.h" #include "assert.h"
#ifdef ANSI
#include <flt_arith.h>
#endif ANSI
#include "arith.h" /* definition arith */ #include "arith.h" /* definition arith */
#include "label.h" /* definition label */ #include "label.h" /* definition label */
#include "expr.h" #include "expr.h"
@ -23,7 +26,6 @@
#include "stack.h" #include "stack.h"
#include "type.h" #include "type.h"
#include "level.h" #include "level.h"
#include "nofloat.h"
#include "l_lint.h" #include "l_lint.h"
#include "l_state.h" #include "l_state.h"

View file

@ -13,6 +13,9 @@
#include "debug.h" #include "debug.h"
#include "interface.h" #include "interface.h"
#include "assert.h" #include "assert.h"
#ifdef ANSI
#include <flt_arith.h>
#endif ANSI
#include "arith.h" /* definition arith */ #include "arith.h" /* definition arith */
#include "label.h" /* definition label */ #include "label.h" /* definition label */
#include "expr.h" #include "expr.h"
@ -24,7 +27,6 @@
#include "stack.h" #include "stack.h"
#include "type.h" #include "type.h"
#include "level.h" #include "level.h"
#include "nofloat.h"
#include "l_lint.h" #include "l_lint.h"
#include "l_state.h" #include "l_state.h"
#include "l_outdef.h" #include "l_outdef.h"

View file

@ -11,6 +11,9 @@
#include <alloc.h> /* for st_free */ #include <alloc.h> /* for st_free */
#include "interface.h" #include "interface.h"
#ifdef ANSI
#include <flt_arith.h>
#endif ANSI
#include "arith.h" /* definition arith */ #include "arith.h" /* definition arith */
#include "label.h" /* definition label */ #include "label.h" /* definition label */
#include "expr.h" #include "expr.h"
@ -22,7 +25,6 @@
#include "stack.h" #include "stack.h"
#include "type.h" #include "type.h"
#include "level.h" #include "level.h"
#include "nofloat.h"
#include "l_state.h" #include "l_state.h"
extern char *symbol2str(); extern char *symbol2str();
@ -32,6 +34,32 @@ PRIVATE lint_enum_arith();
PRIVATE lint_conversion(); PRIVATE lint_conversion();
PRIVATE int numsize(); 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) lint_new_oper(expr)
struct expr *expr; struct expr *expr;
{ {

View file

@ -11,9 +11,14 @@
#include <alloc.h> #include <alloc.h>
#include "interface.h" #include "interface.h"
#ifdef ANSI
#include <flt_arith.h>
#endif ANSI
#include "arith.h" #include "arith.h"
#include "assert.h" #include "assert.h"
#include "type.h" #include "type.h"
#include "declar.h"
#include "decspecs.h"
#include "LLlex.h" #include "LLlex.h"
#include "Lpars.h" #include "Lpars.h"
#include "stack.h" #include "stack.h"
@ -45,7 +50,6 @@ PRIVATE outargs();
PRIVATE outarg(); PRIVATE outarg();
PRIVATE outargstring(); PRIVATE outargstring();
PRIVATE outargtype(); PRIVATE outargtype();
PRIVATE implicit_func_decl();
PRIVATE fill_arg(); PRIVATE fill_arg();
lint_declare_idf(idf, sc) 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) lint_ext_def(idf, sc)
struct idf *idf; struct idf *idf;
{ {
@ -466,6 +483,7 @@ outargtype(tp)
} }
} }
#ifdef IMPLICIT
PRIVATE PRIVATE
implicit_func_decl(idf, file, line) implicit_func_decl(idf, file, line)
struct idf *idf; struct idf *idf;
@ -483,6 +501,7 @@ implicit_func_decl(idf, file, line)
output_def(&od); output_def(&od);
/* The other fields are not used for this class. */ /* The other fields are not used for this class. */
} }
#endif IMPLICIT
fill_outcall(ex, used) fill_outcall(ex, used)
struct expr *ex; struct expr *ex;
@ -491,10 +510,12 @@ fill_outcall(ex, used)
register struct idf *idf = ex->OP_LEFT->VL_IDF; register struct idf *idf = ex->OP_LEFT->VL_IDF;
register struct def *def = idf->id_def; register struct def *def = idf->id_def;
#ifdef IMPLICIT
if (def->df_sc == IMPLICIT && !idf->id_def->df_used) { if (def->df_sc == IMPLICIT && !idf->id_def->df_used) {
/* IFDC, first time */ /* IFDC, first time */
implicit_func_decl(idf, ex->ex_file, ex->ex_line); implicit_func_decl(idf, ex->ex_file, ex->ex_line);
} }
#endif IMPLICIT
OutCall.od_type = def->df_type->tp_up; OutCall.od_type = def->df_type->tp_up;
OutCall.od_statnr = (def->df_sc == STATIC ? stat_number : 0); OutCall.od_statnr = (def->df_sc == STATIC ? stat_number : 0);

View file

@ -13,6 +13,9 @@
#include "interface.h" #include "interface.h"
#include "assert.h" #include "assert.h"
#include "debug.h" #include "debug.h"
#ifdef ANSI
#include <flt_arith.h>
#endif ANSI
#include "arith.h" #include "arith.h"
#include "label.h" #include "label.h"
#include "expr.h" #include "expr.h"
@ -24,7 +27,6 @@
#include "stack.h" #include "stack.h"
#include "type.h" #include "type.h"
#include "level.h" #include "level.h"
#include "nofloat.h"
#include "l_lint.h" #include "l_lint.h"
#include "l_brace.h" #include "l_brace.h"
#include "l_state.h" #include "l_state.h"
@ -201,7 +203,9 @@ lint_1_global(idf, def)
case STATIC: case STATIC:
case EXTERN: case EXTERN:
case GLOBAL: case GLOBAL:
#ifdef IMPLICIT
case IMPLICIT: case IMPLICIT:
#endif IMPLICIT
if (fund == ERRONEOUS) if (fund == ERRONEOUS)
break; break;

View file

@ -161,10 +161,7 @@ non_function(register struct decspecs *ds; register struct declarator *dc;)
] ]
{ {
#ifdef LINT #ifdef LINT
if (dc->dc_idf->id_def->df_type->tp_fund == FUNCTION) lint_non_function_decl(ds, dc);
def2decl(ds->ds_sc);
if (dc->dc_idf->id_def->df_sc != TYPEDEF)
outdef();
#endif LINT #endif LINT
} }
[ [

View file

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

View file

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

View file

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

View file

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