From 82cf7004e351c9003af3019b2f7434ed8eeabf3e Mon Sep 17 00:00:00 2001 From: Carson Fleming Date: Fri, 17 Jul 2026 01:35:52 -0400 Subject: compute return type size correctly on decl --- codegen.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'codegen.c') diff --git a/codegen.c b/codegen.c index 749c85d..ae94d9f 100644 --- a/codegen.c +++ b/codegen.c @@ -496,9 +496,10 @@ static void emit_expr( static void emit_return(FILE* outfile, const struct return_node* node) { if (active_fn == NULL) CGEN_PANIC("must be inside a function to return"); + unsigned long long return_type_sz = get_type_size(&active_fn->return_type); if (node->ret_val != NULL) { - if (active_fn->return_type.def->sz == 0) + if (return_type_sz == 0) CGEN_PANIC( "returning a value from void function %s", active_fn->name); @@ -507,9 +508,9 @@ static void emit_return(FILE* outfile, const struct return_node* node) { node->ret_val, &(struct lval_def) { .loc = RV_LOC, - .sz = active_fn->return_type.def->sz, + .sz = return_type_sz, }); - } else if (active_fn->return_type.def->sz > 0) { + } else if (return_type_sz > 0) { CGEN_PANIC( "non-void function %s should return a value", active_fn->name); } -- cgit v1.2.3