From 00876cd9dfcb0860e36de70d53bafb735b8a4bcf Mon Sep 17 00:00:00 2001 From: eck Date: Wed, 10 Jan 1990 17:33:35 +0000 Subject: [PATCH] added alloction dump shrunk some data structures changed some ALLOCDEF's changed setjmp to __setjmp --- lang/cem/cemcom.ansi/LLlex.c | 2 +- lang/cem/cemcom.ansi/Makefile | 16 ++++++++++++ lang/cem/cemcom.ansi/arith.c | 1 + lang/cem/cemcom.ansi/ch3.c | 2 +- lang/cem/cemcom.ansi/ch3bin.c | 1 + lang/cem/cemcom.ansi/ch3mon.c | 1 + lang/cem/cemcom.ansi/code.c | 5 ++-- lang/cem/cemcom.ansi/declar.str | 3 --- lang/cem/cemcom.ansi/declarator.c | 2 +- lang/cem/cemcom.ansi/decspecs.c | 16 +++++++----- lang/cem/cemcom.ansi/domacro.c | 2 +- lang/cem/cemcom.ansi/error.c | 2 +- lang/cem/cemcom.ansi/expr.c | 1 + lang/cem/cemcom.ansi/expr.str | 1 - lang/cem/cemcom.ansi/expression.g | 1 + lang/cem/cemcom.ansi/field.str | 3 +-- lang/cem/cemcom.ansi/idf.c | 2 +- lang/cem/cemcom.ansi/l_misc.c | 1 + lang/cem/cemcom.ansi/l_outdef.c | 1 + lang/cem/cemcom.ansi/l_states.c | 2 +- lang/cem/cemcom.ansi/macro.str | 9 ------- lang/cem/cemcom.ansi/main.c | 36 ++++++++++++++++++++++++-- lang/cem/cemcom.ansi/make.allocd | 6 +++++ lang/cem/cemcom.ansi/make.next | 6 ++++- lang/cem/cemcom.ansi/pragma.c | 2 +- lang/cem/cemcom.ansi/program.g | 1 + lang/cem/cemcom.ansi/proto.c | 6 ++--- lang/cem/cemcom.ansi/proto.str | 2 +- lang/cem/cemcom.ansi/replace.str | 9 ++++++- lang/cem/cemcom.ansi/stack.str | 2 +- lang/cem/cemcom.ansi/struct.str | 2 +- lang/cem/cemcom.ansi/type.c | 1 + lang/cem/cemcom.ansi/type.str | 42 ++++++++++++++++++++++--------- lang/cem/cemcom.ansi/util.c | 1 + 34 files changed, 137 insertions(+), 53 deletions(-) diff --git a/lang/cem/cemcom.ansi/LLlex.c b/lang/cem/cemcom.ansi/LLlex.c index a7851d243..0ea8aa9d6 100644 --- a/lang/cem/cemcom.ansi/LLlex.c +++ b/lang/cem/cemcom.ansi/LLlex.c @@ -5,11 +5,11 @@ /* $Header$ */ /* L E X I C A L A N A L Y Z E R */ +#include "debug.h" #include "lint.h" #include #include "idfsize.h" #include "numsize.h" -#include "debug.h" #include "strsize.h" #include "nopp.h" #include "input.h" diff --git a/lang/cem/cemcom.ansi/Makefile b/lang/cem/cemcom.ansi/Makefile index 61f7b6772..9bf131a12 100644 --- a/lang/cem/cemcom.ansi/Makefile +++ b/lang/cem/cemcom.ansi/Makefile @@ -423,6 +423,7 @@ ch3.o: type.h ch3bin.o: Lpars.h ch3bin.o: arith.h ch3bin.o: botch_free.h +ch3bin.o: debug.h ch3bin.o: expr.h ch3bin.o: idf.h ch3bin.o: label.h @@ -606,10 +607,12 @@ domacro.o: idf.h domacro.o: idfsize.h domacro.o: ifdepth.h domacro.o: input.h +domacro.o: macbuf.h domacro.o: macro.h domacro.o: nopp.h domacro.o: nparams.h domacro.o: parbufsize.h +domacro.o: replace.h domacro.o: spec_arith.h domacro.o: textsize.h replace.o: LLlex.h @@ -677,6 +680,7 @@ type.o: Lpars.h type.o: align.h type.o: arith.h type.o: botch_free.h +type.o: debug.h type.o: decspecs.h type.o: def.h type.o: idf.h @@ -692,14 +696,18 @@ type.o: type.h ch3mon.o: Lpars.h ch3mon.o: arith.h ch3mon.o: botch_free.h +ch3mon.o: debug.h ch3mon.o: def.h ch3mon.o: expr.h ch3mon.o: idf.h ch3mon.o: label.h ch3mon.o: lint.h ch3mon.o: nobitfield.h +ch3mon.o: nocross.h ch3mon.o: nopp.h +ch3mon.o: sizes.h ch3mon.o: spec_arith.h +ch3mon.o: target_sizes.h ch3mon.o: type.h label.o: Lpars.h label.o: arith.h @@ -765,6 +773,7 @@ conversion.o: target_sizes.h conversion.o: type.h util.o: Lpars.h util.o: align.h +util.o: debug.h util.o: def.h util.o: lint.h util.o: nocross.h @@ -879,6 +888,7 @@ l_misc.o: LLlex.h l_misc.o: Lpars.h l_misc.o: arith.h l_misc.o: code.h +l_misc.o: debug.h l_misc.o: def.h l_misc.o: expr.h l_misc.o: file_info.h @@ -999,19 +1009,24 @@ expression.o: LLlex.h expression.o: Lpars.h expression.o: arith.h expression.o: code.h +expression.o: debug.h expression.o: expr.h expression.o: file_info.h expression.o: idf.h expression.o: label.h expression.o: lint.h expression.o: nobitfield.h +expression.o: nocross.h expression.o: nopp.h +expression.o: sizes.h expression.o: spec_arith.h +expression.o: target_sizes.h expression.o: type.h program.o: LLlex.h program.o: Lpars.h program.o: arith.h program.o: code.h +program.o: debug.h program.o: declar.h program.o: decspecs.h program.o: def.h @@ -1052,3 +1067,4 @@ ival.o: target_sizes.h ival.o: type.h char.o: class.h symbol2str.o: Lpars.h +next.o: debug.h diff --git a/lang/cem/cemcom.ansi/arith.c b/lang/cem/cemcom.ansi/arith.c index dea510fe7..6d8c03236 100644 --- a/lang/cem/cemcom.ansi/arith.c +++ b/lang/cem/cemcom.ansi/arith.c @@ -12,6 +12,7 @@ */ #include +#include "debug.h" #include "lint.h" #include "nobitfield.h" #include "idf.h" diff --git a/lang/cem/cemcom.ansi/ch3.c b/lang/cem/cemcom.ansi/ch3.c index 4808442fa..1b2b844e2 100644 --- a/lang/cem/cemcom.ansi/ch3.c +++ b/lang/cem/cemcom.ansi/ch3.c @@ -5,8 +5,8 @@ /* $Header$ */ /* S E M A N T I C A N A L Y S I S -- C H A P T E R 3.3 */ -#include "lint.h" #include "debug.h" +#include "lint.h" #include "nobitfield.h" #include "idf.h" #include diff --git a/lang/cem/cemcom.ansi/ch3bin.c b/lang/cem/cemcom.ansi/ch3bin.c index 6a65a7a32..9604695b7 100644 --- a/lang/cem/cemcom.ansi/ch3bin.c +++ b/lang/cem/cemcom.ansi/ch3bin.c @@ -6,6 +6,7 @@ /* SEMANTIC ANALYSIS (CHAPTER 3.3) -- BINARY OPERATORS */ #include "botch_free.h" +#include "debug.h" #include #include "lint.h" #include "idf.h" diff --git a/lang/cem/cemcom.ansi/ch3mon.c b/lang/cem/cemcom.ansi/ch3mon.c index 801b2f917..b7794865d 100644 --- a/lang/cem/cemcom.ansi/ch3mon.c +++ b/lang/cem/cemcom.ansi/ch3mon.c @@ -6,6 +6,7 @@ /* SEMANTIC ANALYSIS (CHAPTER 3.3) -- MONADIC OPERATORS */ #include "botch_free.h" +#include "debug.h" #include #include "nobitfield.h" #include "Lpars.h" diff --git a/lang/cem/cemcom.ansi/code.c b/lang/cem/cemcom.ansi/code.c index d5874ea8b..dd1ad154f 100644 --- a/lang/cem/cemcom.ansi/code.c +++ b/lang/cem/cemcom.ansi/code.c @@ -6,6 +6,7 @@ /* C O D E - G E N E R A T I N G R O U T I N E S */ #include "lint.h" +#include "debug.h" #include #include "botch_free.h" #include @@ -260,7 +261,7 @@ end_proc(fbytes) - indication of the use of floating points - indication of the number of bytes used for formal parameters - - use of special identifiers such as "setjmp" + - use of special identifiers such as "__setjmp" - "end" + number of bytes used for local variables */ arith nbytes; @@ -304,7 +305,7 @@ end_proc(fbytes) func_name, (long) max_int); } C_ms_par(fbytes); /* # bytes for formals */ - if (sp_occurred[SP_SETJMP]) { /* indicate use of "setjmp" */ + if (sp_occurred[SP_SETJMP]) { /* indicate use of "__setjmp" */ options['n'] = 1; C_ms_gto(); sp_occurred[SP_SETJMP] = 0; diff --git a/lang/cem/cemcom.ansi/declar.str b/lang/cem/cemcom.ansi/declar.str index 640fc3ad7..ad812be02 100644 --- a/lang/cem/cemcom.ansi/declar.str +++ b/lang/cem/cemcom.ansi/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.ansi/declarator.c b/lang/cem/cemcom.ansi/declarator.c index 318473fda..ae3897d60 100644 --- a/lang/cem/cemcom.ansi/declarator.c +++ b/lang/cem/cemcom.ansi/declarator.c @@ -5,6 +5,7 @@ /* $Header$ */ /* D E C L A R A T O R M A N I P U L A T I O N */ +#include "debug.h" #include "botch_free.h" #include #include @@ -18,7 +19,6 @@ #include "label.h" #include "expr.h" #include "sizes.h" -#include "debug.h" #include "level.h" extern char options[]; diff --git a/lang/cem/cemcom.ansi/decspecs.c b/lang/cem/cemcom.ansi/decspecs.c index fe088f966..aa266f5ce 100644 --- a/lang/cem/cemcom.ansi/decspecs.c +++ b/lang/cem/cemcom.ansi/decspecs.c @@ -153,25 +153,29 @@ qualifier_type(tp, typequal) dtp->tp_align = tp->tp_align; dtp->tp_typequal = typequal; dtp->tp_size = tp->tp_size; + dtp->tp_pointer = tp->tp_pointer; + dtp->tp_array = tp->tp_array; + dtp->tp_function = tp->tp_function; switch (fund) { case ARRAY: if (typequal) { tp->tp_up = qualifier_type(tp->tp_up, typequal); dtp->tp_typequal = typequal = 0; } + goto nottagged; + case FIELD: + dtp->tp_field = tp->tp_field; /* fallthrough */ case POINTER: - case FUNCTION: + case FUNCTION: /* dont't assign tp_proto */ + nottagged: + dtp->tp_up = tp->tp_up; + break; case STRUCT: case UNION: case ENUM: dtp->tp_idf = tp->tp_idf; dtp->tp_sdef = tp->tp_sdef; - dtp->tp_up = tp->tp_up; - dtp->tp_field = tp->tp_field; - dtp->tp_pointer = tp->tp_pointer; - dtp->tp_array = tp->tp_array; - dtp->tp_function = tp->tp_function; break; default: break; diff --git a/lang/cem/cemcom.ansi/domacro.c b/lang/cem/cemcom.ansi/domacro.c index abc73e6f1..5c602323a 100644 --- a/lang/cem/cemcom.ansi/domacro.c +++ b/lang/cem/cemcom.ansi/domacro.c @@ -5,10 +5,10 @@ /* $Header$ */ /* PREPROCESSOR: CONTROLLINE INTERPRETER */ +#include "debug.h" #include "arith.h" #include "LLlex.h" #include "Lpars.h" -#include "debug.h" #include "idf.h" #include "input.h" #include "nopp.h" diff --git a/lang/cem/cemcom.ansi/error.c b/lang/cem/cemcom.ansi/error.c index 85374e38d..797da2f84 100644 --- a/lang/cem/cemcom.ansi/error.c +++ b/lang/cem/cemcom.ansi/error.c @@ -9,10 +9,10 @@ #include #include +#include "debug.h" #include "lint.h" #include "nopp.h" #include "errout.h" -#include "debug.h" #include "tokenname.h" #include diff --git a/lang/cem/cemcom.ansi/expr.c b/lang/cem/cemcom.ansi/expr.c index 8a46fbe4b..7b6d562b6 100644 --- a/lang/cem/cemcom.ansi/expr.c +++ b/lang/cem/cemcom.ansi/expr.c @@ -6,6 +6,7 @@ /* EXPRESSION TREE HANDLING */ #include "lint.h" +#include "debug.h" #include "assert.h" #include "botch_free.h" #include diff --git a/lang/cem/cemcom.ansi/expr.str b/lang/cem/cemcom.ansi/expr.str index 3a43a730e..197028236 100644 --- a/lang/cem/cemcom.ansi/expr.str +++ b/lang/cem/cemcom.ansi/expr.str @@ -50,7 +50,6 @@ struct oper { #define Type 4 /* only its type is relevant */ struct expr { - struct expr *next; char *ex_file; /* the file it (probably) comes from */ unsigned int ex_line; /* the line it (probably) comes from */ struct type *ex_type; diff --git a/lang/cem/cemcom.ansi/expression.g b/lang/cem/cemcom.ansi/expression.g index 2771b4d27..b7310535d 100644 --- a/lang/cem/cemcom.ansi/expression.g +++ b/lang/cem/cemcom.ansi/expression.g @@ -8,6 +8,7 @@ { #include #include "lint.h" +#include "debug.h" #include #include "arith.h" #include "LLlex.h" diff --git a/lang/cem/cemcom.ansi/field.str b/lang/cem/cemcom.ansi/field.str index 520c9abc6..76fdd5afd 100644 --- a/lang/cem/cemcom.ansi/field.str +++ b/lang/cem/cemcom.ansi/field.str @@ -6,11 +6,10 @@ /* FIELD DESCRIPTOR */ struct field { /* for field specifiers */ - struct field *next; arith fd_mask; int fd_shift; int fd_width; struct sdef *fd_sdef; /* upward pointer */ }; -/* ALLOCDEF "field" 50 */ +/* ALLOCDEF "field" 10 */ diff --git a/lang/cem/cemcom.ansi/idf.c b/lang/cem/cemcom.ansi/idf.c index 2a93633b4..f01832af0 100644 --- a/lang/cem/cemcom.ansi/idf.c +++ b/lang/cem/cemcom.ansi/idf.c @@ -77,7 +77,7 @@ idf_hashed(tg, size, hc) break; if (cmp == 0) { /* suppose that special identifiers, as - "setjmp", are already inserted + "__setjmp", are already inserted */ sp_occurred[notch->id_special] = 1; return notch; diff --git a/lang/cem/cemcom.ansi/l_misc.c b/lang/cem/cemcom.ansi/l_misc.c index b706930c2..e558e530f 100644 --- a/lang/cem/cemcom.ansi/l_misc.c +++ b/lang/cem/cemcom.ansi/l_misc.c @@ -10,6 +10,7 @@ #ifdef LINT #include /* for st_free */ +#include "debug.h" #include "interface.h" #include #include "arith.h" /* definition arith */ diff --git a/lang/cem/cemcom.ansi/l_outdef.c b/lang/cem/cemcom.ansi/l_outdef.c index a01cb06f5..b29b6140b 100644 --- a/lang/cem/cemcom.ansi/l_outdef.c +++ b/lang/cem/cemcom.ansi/l_outdef.c @@ -10,6 +10,7 @@ #ifdef LINT #include +#include "debug.h" #include "interface.h" #include #include "arith.h" diff --git a/lang/cem/cemcom.ansi/l_states.c b/lang/cem/cemcom.ansi/l_states.c index 0c4fb90a1..463276ada 100644 --- a/lang/cem/cemcom.ansi/l_states.c +++ b/lang/cem/cemcom.ansi/l_states.c @@ -10,9 +10,9 @@ #ifdef LINT #include /* for st_free */ +#include "debug.h" #include "interface.h" #include "assert.h" -#include "debug.h" #include #include "arith.h" /* definition arith */ #include "label.h" /* definition label */ diff --git a/lang/cem/cemcom.ansi/macro.str b/lang/cem/cemcom.ansi/macro.str index ae0692269..c6fd0ea8b 100644 --- a/lang/cem/cemcom.ansi/macro.str +++ b/lang/cem/cemcom.ansi/macro.str @@ -33,15 +33,6 @@ struct macro { /* ALLOCDEF "macro" 20 */ -struct mlist { - struct mlist *next; - struct macro *m_mac; - char *m_repl; - char m_unstack; -}; - -/* ALLOCDEF "mlist" 20 */ - /* `token' numbers of keywords of command-line processor */ #define K_UNKNOWN 0 diff --git a/lang/cem/cemcom.ansi/main.c b/lang/cem/cemcom.ansi/main.c index 9448afc2a..292ee2327 100644 --- a/lang/cem/cemcom.ansi/main.c +++ b/lang/cem/cemcom.ansi/main.c @@ -7,9 +7,9 @@ #include "lint.h" #include +#include "debug.h" #include "nopp.h" #include "target_sizes.h" -#include "debug.h" #include "use_tmp.h" #include "inputtype.h" #include "input.h" @@ -42,7 +42,7 @@ extern char *getwdir(); #endif NOPP struct sp_id special_ids[] = { - {"setjmp", SP_SETJMP}, /* non-local goto's are registered */ + {"__setjmp", SP_SETJMP}, /* non-local goto's are registered */ {0, 0} }; @@ -116,6 +116,7 @@ main(argc, argv) #ifdef DEBUG hash_stat(); + if (options['m']) Info(); #endif DEBUG sys_stop(err_occurred ? S_EXIT : S_END); @@ -382,6 +383,37 @@ preprocess() } } #endif NOPP + +Info() +{ + extern int cnt_string_cst, cnt_formal, + cnt_decl_unary, cnt_def, cnt_expr, cnt_field, + cnt_e_stack, cnt_localvar, cnt_proto, cnt_repl, + cnt_args, cnt_idf, cnt_macro, cnt_stack_level, + cnt_stack_entry, cnt_stmt_block, cnt_sdef, cnt_tag, + cnt_switch_hdr, cnt_case_entry, cnt_type, cnt_brace, + cnt_lint_stack_entry, cnt_state, cnt_auto_def, + cnt_expr_state, cnt_argument; + print("\ +%6d string_cst\n%6d formal\n\ +%6d decl_unary\n%6d def\n%6d expr\n%6d field\n\ +%6d e_stack\n%6d localvar\n%6d proto\n%6d repl\n\ +%6d args\n%6d idf\n%6d macro\n%6d stack_level\n\ +%6d stack_entry\n%6d stmt_block\n%6d sdef\n%6d tag\n\ +%6d switch_hdr\n%6d case_entry\n%6d type\n%6d brace\n\ +%6d lint_stack_entry\n%6d state\n%6d auto_def\n\ +%6d expr_state\n%6d argument\n", + cnt_string_cst, cnt_formal, + cnt_decl_unary, cnt_def, cnt_expr, cnt_field, + cnt_e_stack, cnt_localvar, cnt_proto, cnt_repl, + cnt_args, cnt_idf, cnt_macro, cnt_stack_level, + cnt_stack_entry, cnt_stmt_block, cnt_sdef, cnt_tag, + cnt_switch_hdr, cnt_case_entry, cnt_type, cnt_brace, + cnt_lint_stack_entry, cnt_state, cnt_auto_def, + cnt_expr_state, cnt_argument); + + +} #endif DEBUG No_Mem() /* called by alloc package */ diff --git a/lang/cem/cemcom.ansi/make.allocd b/lang/cem/cemcom.ansi/make.allocd index 08492fad1..2289a4d51 100755 --- a/lang/cem/cemcom.ansi/make.allocd +++ b/lang/cem/cemcom.ansi/make.allocd @@ -3,6 +3,12 @@ s:^.*[ ]ALLOCDEF[ ].*"\(.*\)"[ ]*\([0-9][0-9]*\).*$:\ /* allocation definitions of struct \1 */\ extern char *st_alloc();\ extern struct \1 *h_\1;\ +#ifdef DEBUG\ +extern int cnt_\1;\ +extern char *std_alloc();\ +#define new_\1() ((struct \1 *) std_alloc((char **)\&h_\1, sizeof(struct \1), \2, \&cnt_\1))\ +#else\ #define new_\1() ((struct \1 *) st_alloc((char **)\&h_\1, sizeof(struct \1), \2))\ +#endif\ #define free_\1(p) st_free(p, \&h_\1, sizeof(struct \1))\ :' diff --git a/lang/cem/cemcom.ansi/make.next b/lang/cem/cemcom.ansi/make.next index be69d8d69..ca293cf8d 100755 --- a/lang/cem/cemcom.ansi/make.next +++ b/lang/cem/cemcom.ansi/make.next @@ -1,3 +1,7 @@ +echo '#include "debug.h"' sed -n ' -s:^.*ALLOCDEF.*"\(.*\)".*$:struct \1 *h_\1 = 0;:p +s:^.*ALLOCDEF.*"\(.*\)".*$:struct \1 *h_\1 = 0;\ +#ifdef DEBUG\ +int cnt_\1 = 0;\ +#endif:p ' $* diff --git a/lang/cem/cemcom.ansi/pragma.c b/lang/cem/cemcom.ansi/pragma.c index 7e9ce686d..6d52290e5 100644 --- a/lang/cem/cemcom.ansi/pragma.c +++ b/lang/cem/cemcom.ansi/pragma.c @@ -5,10 +5,10 @@ /* $Header$ */ /* PREPROCESSOR: PRAGMA INTERPRETER */ +#include "debug.h" #include "arith.h" #include "LLlex.h" #include "Lpars.h" -#include "debug.h" #include "idf.h" #include "input.h" #include "ifdepth.h" diff --git a/lang/cem/cemcom.ansi/program.g b/lang/cem/cemcom.ansi/program.g index adbeef404..0e180e6bd 100644 --- a/lang/cem/cemcom.ansi/program.g +++ b/lang/cem/cemcom.ansi/program.g @@ -47,6 +47,7 @@ { #include "lint.h" #include "nopp.h" +#include "debug.h" #include #include "arith.h" #include "LLlex.h" diff --git a/lang/cem/cemcom.ansi/proto.c b/lang/cem/cemcom.ansi/proto.c index e74e54444..561525ee9 100644 --- a/lang/cem/cemcom.ansi/proto.c +++ b/lang/cem/cemcom.ansi/proto.c @@ -278,7 +278,7 @@ update_proto(tp, otp) return; } - while (tp && tp->tp_fund != FUNCTION) { + while (tp->tp_fund != FUNCTION) { tp = tp->tp_up; otp = otp->tp_up; if (!tp) return; @@ -463,10 +463,10 @@ call_proto(expp) any2parameter(estack[ecnt]); } if (pcnt >= 0 && !(pstack[0]->pl_flag & PL_ELLIPSIS)) - expr_error(*expp, "less parameters than specified in prototype"); + expr_error(*expp, "fewer parameters than specified in prototype"); } else { if (pl && !(pl->pl_flag & PL_VOID)) - expr_error(*expp, "less parameters than specified in prototype"); + expr_error(*expp, "fewer parameters than specified in prototype"); } } diff --git a/lang/cem/cemcom.ansi/proto.str b/lang/cem/cemcom.ansi/proto.str index 946c78080..6bdf4ca97 100644 --- a/lang/cem/cemcom.ansi/proto.str +++ b/lang/cem/cemcom.ansi/proto.str @@ -19,4 +19,4 @@ struct proto { #define PL_ELLIPSIS 0x04 #define PL_ERRGIVEN 0x08 -/* ALLOCDEF "proto" 10 */ +/* ALLOCDEF "proto" 20 */ diff --git a/lang/cem/cemcom.ansi/replace.str b/lang/cem/cemcom.ansi/replace.str index 122d1b96d..06948a16f 100644 --- a/lang/cem/cemcom.ansi/replace.str +++ b/lang/cem/cemcom.ansi/replace.str @@ -1,3 +1,10 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Header$ */ +/* DEFINITIONS FOR THE MACRO REPLACEMENT ROUTINES */ + struct repl { struct repl *next; struct idf *r_idf; /* name of the macro */ @@ -22,7 +29,7 @@ struct repl { #define ABCD 2 #define g(x, y) x ## y + h(x) - g(ABC, D); + g(ABC, D); // gives: 2 + h(f()) In this case we need two copies: one raw copy for the pasting operator, and an expanded one as argument for h(). diff --git a/lang/cem/cemcom.ansi/stack.str b/lang/cem/cemcom.ansi/stack.str index fc32c8726..3c2447a6d 100644 --- a/lang/cem/cemcom.ansi/stack.str +++ b/lang/cem/cemcom.ansi/stack.str @@ -27,7 +27,7 @@ struct stack_entry { struct idf *se_idf; }; -/* ALLOCDEF "stack_entry" 5 */ +/* ALLOCDEF "stack_entry" 50 */ extern struct stack_level *local_level; extern struct stack_level *stack_level_of(); diff --git a/lang/cem/cemcom.ansi/struct.str b/lang/cem/cemcom.ansi/struct.str index 7a9c0e4ee..1e41050f6 100644 --- a/lang/cem/cemcom.ansi/struct.str +++ b/lang/cem/cemcom.ansi/struct.str @@ -25,6 +25,6 @@ struct tag { /* for struct-, union- and enum tags */ }; -/* ALLOCDEF "tag" 50 */ +/* ALLOCDEF "tag" 10 */ struct sdef *idf2sdef(); diff --git a/lang/cem/cemcom.ansi/type.c b/lang/cem/cemcom.ansi/type.c index e587e3bb9..0b07e9473 100644 --- a/lang/cem/cemcom.ansi/type.c +++ b/lang/cem/cemcom.ansi/type.c @@ -6,6 +6,7 @@ /* T Y P E D E F I N I T I O N M E C H A N I S M */ #include "nobitfield.h" +#include "debug.h" #include "botch_free.h" #include #include "Lpars.h" diff --git a/lang/cem/cemcom.ansi/type.str b/lang/cem/cemcom.ansi/type.str index c826da5eb..878e1a254 100644 --- a/lang/cem/cemcom.ansi/type.str +++ b/lang/cem/cemcom.ansi/type.str @@ -8,24 +8,42 @@ #include "nobitfield.h" struct type { - struct type *next; /* used only with ARRAY */ + struct type *next; /* used for ARRAY and for qualifiers */ short tp_fund; /* fundamental type */ short tp_unsigned; int tp_align; int tp_typequal; /* type qualifier */ arith tp_size; /* -1 if declared but not defined */ - struct idf *tp_idf; /* name of STRUCT, UNION or ENUM */ - struct sdef *tp_sdef; /* to first selector */ - struct type *tp_up; /* from FIELD, POINTER, ARRAY - or FUNCTION to fund. */ - struct field *tp_field; /* field descriptor if fund == FIELD */ - struct type *tp_pointer;/* to POINTER */ - struct type *tp_array; /* to ARRAY */ - struct proto *tp_proto; /* prototype list */ - struct proto *tp_pseudoproto; /* pseudo prototype list */ - struct type *tp_function;/* to FUNCTION */ + struct type *tp_pointer; /* to POINTER */ + struct type *tp_array; /* to ARRAY */ + struct type *tp_function; /* to FUNCTION */ + union { + struct { + struct idf *tp__idf; /* name of STRUCT, UNION or ENUM */ + struct sdef *tp__sdef; /* to first selector */ + } tp_istagged; /* used with STRUCT, UNION & ENUM */ + struct { + /* tp__up: from FIELD, POINTER, ARRAY or FUNCTION to fund. */ + struct type *tp__up; + union { + /* tp__field: field descriptor if fund == FIELD */ + struct field *tp__field; + struct { + /* prototype list (pseudoproto for old_style def) */ + struct proto *tp__proto; + struct proto *tp__pseudoproto; + } tp_isfunc; + } tp_f; /* FIELD or FUNCTION */ + } tp_nottagged; /* used with POINTER, FIELD, ARRAY & FUNCTION */ + } tp_union; }; +#define tp_idf tp_union.tp_istagged.tp__idf +#define tp_sdef tp_union.tp_istagged.tp__sdef +#define tp_up tp_union.tp_nottagged.tp__up +#define tp_field tp_union.tp_nottagged.tp_f.tp__field +#define tp_proto tp_union.tp_nottagged.tp_f.tp_isfunc.tp__proto +#define tp_pseudoproto tp_union.tp_nottagged.tp_f.tp_isfunc.tp__pseudoproto /* Type qualifiers. Note: TQ_VOLATILE and TQ_CONST can be 'ored' to specify: extern const volatile int a; @@ -55,4 +73,4 @@ extern struct type *pa_type; /* type.c */ extern arith size_of_type(), align(); -/* ALLOCDEF "type" 20 */ +/* ALLOCDEF "type" 50 */ diff --git a/lang/cem/cemcom.ansi/util.c b/lang/cem/cemcom.ansi/util.c index b8724409e..495e1abb1 100644 --- a/lang/cem/cemcom.ansi/util.c +++ b/lang/cem/cemcom.ansi/util.c @@ -17,6 +17,7 @@ #include #include "lint.h" +#include "debug.h" #include "util.h" #include "use_tmp.h" #include "regcount.h" -- 2.34.1