From 14ac6853301e5527f3e699972aa04f4f05ad0145 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 11 Dec 2024 23:16:57 +0900 Subject: [PATCH] [qfcc] Initialize parameters with their arguments However, once past a couple of errors, they're not getting initialized in the spir-v, so I've probably missed something there. For now I've kept things simple and made them regular variables regardless of qualifiers (and no support for out/inout yet). --- tools/qfcc/source/expr_call.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/qfcc/source/expr_call.c b/tools/qfcc/source/expr_call.c index 090f9fb2b..843fb3747 100644 --- a/tools/qfcc/source/expr_call.c +++ b/tools/qfcc/source/expr_call.c @@ -233,7 +233,11 @@ build_inline_call (symbol_t *fsym, const type_t *ftype, auto params = func->parameters; auto locals = func->locals; - for (auto p = fsym->params; p; p = p->next) { + auto call = new_block_expr (nullptr); + call->block.scope = locals; + + int i = 0; + for (auto p = fsym->params; p; p = p->next, i++) { if (!p->selector && !p->type && !p->name) { internal_error (0, "inline variadic not implemented"); } @@ -254,13 +258,15 @@ build_inline_call (symbol_t *fsym, const type_t *ftype, notice (0, "parameter name omitted"); continue; } - auto param = new_symbol_type (p->name, p->type); - symtab_addsymbol (params, param); + auto spec = (specifier_t) { + .type = p->type, + .storage = sc_local, + }; + auto decl = new_decl_expr (spec, params); + append_decl (decl, new_symbol (p->name), arguments[i]); + append_expr (call, decl); } - auto call = new_block_expr (nullptr); - call->block.scope = locals; - if (!is_void (ftype->func.ret_type)) { auto spec = (specifier_t) { .type = ftype->func.ret_type,