summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--codegen.c7
1 files changed, 4 insertions, 3 deletions
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);
}