From 0db617719e39faa16381d2c5cfa95d3d6850375c Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 2 Mar 2020 13:31:26 +0900 Subject: [PATCH] [qfcc] Improve error messages for bad qc builtins While global quakec functions could not be initialized to another function, the error messages were rather obscure. --- tools/qfcc/source/qc-parse.y | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index a7b353082..8d939185b 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -1014,11 +1014,20 @@ non_code_func } | '=' expr { - symbol_t *sym = $0; - specifier_t spec = $-1; - initialize_def (sym, $2, current_symtab->space, spec.storage); - if (sym->s.def) - sym->s.def->nosave |= spec.nosave; + if (local_expr) { + symbol_t *sym = $0; + specifier_t spec = $-1; + initialize_def (sym, $2, current_symtab->space, spec.storage); + if (sym->s.def) + sym->s.def->nosave |= spec.nosave; + } else { + if (is_integer_val ($2) || is_float_val ($2)) { + error (0, "invalid function initializer." + " did you forget #?"); + } else { + error (0, "cannot create global function variables"); + } + } } | /* emtpy */ {