From a2b5ebde65b017c61944d7c752eb9fb68adaed38 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 11 Feb 2023 14:44:55 +0900 Subject: [PATCH] [qfcc] Treat parameter shadowing as an error This applies only to the top-level scope of the function. I'm not sure if it's right for traditional quakec code, but that can be adjusted easily enough. --- tools/qfcc/source/def.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/qfcc/source/def.c b/tools/qfcc/source/def.c index 76286dce6..f87803f2c 100644 --- a/tools/qfcc/source/def.c +++ b/tools/qfcc/source/def.c @@ -536,6 +536,10 @@ initialize_def (symbol_t *sym, expr_t *init, defspace_t *space, symbol_t *check = symtab_lookup (symtab, sym->name); reloc_t *relocs = 0; + if (check && symtab->parent && check->table == symtab->parent->parent + && symtab->parent->parent->type == stab_param) { + error (0, "%s shadows a parameter", sym->name); + } if (check && check->table == symtab) { if (check->sy_type != sy_var || !type_same (check->type, sym->type)) { error (0, "%s redefined", sym->name);