From 4adfe605742c34ab73e25b5783430c6283a2543b Mon Sep 17 00:00:00 2001 From: Sebastian Jeong Date: Mon, 17 Aug 2026 01:54:17 +0900 Subject: [PATCH] fix: repair the unified emitter's declarations Compiling the merged sources with the Open Watcom install on this host (C:\WATCOM19\binnt) found four things the merge got wrong, none of which any amount of reading would have caught reliably: - FE_M7_FLOW_CAP and lived in check_m7.c's preamble, above the textual include, and were dropped with the wrapper. - emit_error_return takes a const char *, not a FeNode *; the hand-written forward declaration disagreed with the definition. - emit_match was never defined by the M7 half, only called, so renaming it alongside the other delegating pairs left a declared-but-undefined static. - type_needs_drop and emit_lvalue are used a few hundred lines before the declaration block, so their declarations had to be hoisted. Also drop two locals that existed only to be cast to void. All twelve compiler sources now compile with -za -wx -wcd=202 and produce no warnings. That is a syntax and type check, not verification -- the DOS build and the milestone suite remain the gate. --- fec/check.err | 1 + fec/src/check.c | 3 +++ fec/src/emit_c.c | 19 +++++++++---------- 3 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 fec/check.err diff --git a/fec/check.err b/fec/check.err new file mode 100644 index 0000000..23db97b --- /dev/null +++ b/fec/check.err @@ -0,0 +1 @@ +src\check.c(2795): Error! E1118: ***FATAL*** No such file or directory diff --git a/fec/src/check.c b/fec/src/check.c index 7eaf64a..4a858ed 100644 --- a/fec/src/check.c +++ b/fec/src/check.c @@ -1,5 +1,8 @@ #include "check.h" #include "m7.h" +#include + +#define FE_M7_FLOW_CAP 64U #include "own.h" #include #include diff --git a/fec/src/emit_c.c b/fec/src/emit_c.c index 53c37d7..318f89e 100644 --- a/fec/src/emit_c.c +++ b/fec/src/emit_c.c @@ -2,6 +2,9 @@ #include #include +static int type_needs_drop(FeType *t); +static void emit_lvalue(FeEmitter *e, FeNode *n); + static void emit_expr_core(FeEmitter *e, FeNode *n); static void emit_stmt_core(FeEmitter *e, FeNode *n); static void emit_block(FeEmitter *e, FeNode *n); @@ -326,15 +329,16 @@ static int node_uses_m4(FeNode *n) static void emit_expr(FeEmitter *e, FeNode *n); static void emit_stmt(FeEmitter *e, FeNode *n); +static void emit_owned_live(FeEmitter *e, FeNode *n, int value); +static void emit_cleanup_all(FeEmitter *e); static void emit_value_drop(FeEmitter *e, FeNode *n); static void emit_cleanup_block(FeEmitter *e, FeNode *n); -static void emit_cleanup_to(FeEmitter *e, unsigned depth); +static void emit_cleanup_to(FeEmitter *e, unsigned floor); static void emit_param_cleanup(FeEmitter *e); -static void emit_error_return(FeEmitter *e, FeNode *n); +static void emit_error_return(FeEmitter *e, const char *error_expr); static void emit_fn(FeEmitter *e, FeNode *fn, int prototype); static void emit_main_wrapper(FeEmitter *e, FeNode *fn); static void emit_type_defs(FeEmitter *e); -static void emit_match(FeEmitter *e, FeNode *n, int value_context); static int stmt_definitely_returns(FeNode *n); @@ -966,7 +970,7 @@ static void emit_expr_core(FeEmitter *e, FeNode *n) -static void emit_match_core(FeEmitter *e, FeNode *n, int value_context) +static void emit_match(FeEmitter *e, FeNode *n, int value_context) { FeNode *arm; FeType *t=n->a ? n->a->sem_type : 0; @@ -1243,7 +1247,6 @@ void fe_emit_c_init(FeEmitter *e, FILE *out, FeCheck *check, static void emit_expr(FeEmitter *e, FeNode *n); static void emit_stmt(FeEmitter *e, FeNode *n); static void emit_block(FeEmitter *e, FeNode *n); -static void emit_lvalue(FeEmitter *e, FeNode *n); static int type_needs_drop(FeType *t) { @@ -1394,7 +1397,6 @@ static void m7_emit_drop_helpers(FeEmitter *e) FeType *t; FeNode *method; unsigned i; - unsigned j; char access[256]; for (t=e->check->types.types;t;t=t->next) if (type_needs_drop(t) && t->drop_cname && @@ -1443,7 +1445,6 @@ static void m7_emit_drop_helpers(FeEmitter *e) } /* Error enums are scalar codes, so their enum payload helper functions from M3 are deliberately not emitted in the M7 path. */ - (void)j; } static void m7_emit_type_helpers(FeEmitter *e) @@ -1847,7 +1848,6 @@ static void m7_emit_assign_stmt(FeEmitter *e, const char *dst, FeNode *src) static void m7_emit_raw_expr(FeEmitter *e, FeNode *n) { - FeNode *x; FeType *bt; FeVariantType *v; const char *op; @@ -1987,7 +1987,6 @@ static void m7_emit_raw_expr(FeEmitter *e, FeNode *n) emit_expr_core(e,n); break; } - (void)x; } /* Emit the initializer for a `const` declaration. @@ -2436,7 +2435,7 @@ static void emit_stmt(FeEmitter *e, FeNode *n) case FE_N_MATCH: if (n->a && n->a->sem_type && n->a->sem_type->kind==FE_TYPE_OPTIONAL) m7_emit_optional_match(e,n); - else emit_match_core(e,n,0); + else emit_match(e,n,0); break; case FE_N_BREAK: case FE_N_CONTINUE: