[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.
This commit is contained in:
Bill Currie 2023-02-11 14:44:55 +09:00
parent bc2204d446
commit a2b5ebde65

View file

@ -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);