From 35c0b84ccc46d9d6d1b097994c6a16cc3e9860f5 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 8 Dec 2024 19:16:29 +0900 Subject: [PATCH] [qfcc] Ensure pascal functions always have a block I had never tested empty functions, so I hadn't noticed they cause a segfault. --- tools/qfcc/source/qp-parse.y | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/qfcc/source/qp-parse.y b/tools/qfcc/source/qp-parse.y index ee91ff7ce..6be8bc9ed 100644 --- a/tools/qfcc/source/qp-parse.y +++ b/tools/qfcc/source/qp-parse.y @@ -387,6 +387,10 @@ subprogram_declaration // actual function symbol in rvalue auto fsym = (symbol_t *) sym->xvalue.rvalue; auto statements = $5; + if (!statements) { + statements = new_block_expr (0); + statements->block.scope = current_symtab; + } auto ret_expr = new_return_expr (function_return (current_func)); append_expr (statements, ret_expr); statements = (expr_t *) expr_process (statements, ctx);