diff options
| author | Carson Fleming <cflems@cflems.net> | 2026-07-17 01:35:52 -0400 |
|---|---|---|
| committer | Carson Fleming <cflems@cflems.net> | 2026-07-17 01:35:52 -0400 |
| commit | 82cf7004e351c9003af3019b2f7434ed8eeabf3e (patch) | |
| tree | 1348a4941d65e41aec3a9c084859951876bc15f3 | |
| parent | a5c12fd6f4438fc172f28b722e54908b575c6ce1 (diff) | |
| download | ccc-82cf7004e351c9003af3019b2f7434ed8eeabf3e.tar.gz | |
compute return type size correctly on decl
| -rw-r--r-- | codegen.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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); } |
