[qfcc] Properly dup symbol for declaration

The unification of qc and c function symbol handling made it important
that the new symbol was a proper duplicate (minus being in a table) of
the old symbol. This fixes redeclared prototypes (especially for
qc-style functions, not encountered for c-style). Complete with unit
test :)
This commit is contained in:
Bill Currie 2024-08-30 21:45:37 +09:00
parent ee6e38e2f9
commit 291898b46f
3 changed files with 21 additions and 0 deletions

View file

@ -260,6 +260,8 @@ declare_symbol (specifier_t spec, const expr_t *init, symtab_t *symtab)
// due to the way declarations work, we need a new symbol at all times. // due to the way declarations work, we need a new symbol at all times.
// redelcarations will be checked later // redelcarations will be checked later
s = new_symbol (s->name); s = new_symbol (s->name);
*s = *spec.sym;
s->table = nullptr;
} }
if (!spec.type_expr && !spec.is_function) { if (!spec.type_expr && !spec.is_function) {

View file

@ -57,6 +57,7 @@ test_progs_dat=\
tools/qfcc/test/motor-point.dat \ tools/qfcc/test/motor-point.dat \
tools/qfcc/test/motor-xform.dat \ tools/qfcc/test/motor-xform.dat \
tools/qfcc/test/quaternion.dat \ tools/qfcc/test/quaternion.dat \
tools/qfcc/test/reproto.dat \
tools/qfcc/test/return-ivar.dat \ tools/qfcc/test/return-ivar.dat \
tools/qfcc/test/return-postop.dat \ tools/qfcc/test/return-postop.dat \
tools/qfcc/test/sendv.dat \ tools/qfcc/test/sendv.dat \
@ -692,6 +693,16 @@ tools/qfcc/test/quaternion.run: $(qfcc_test_run_deps)
include $(quaternion_dep) # am--include-marker include $(quaternion_dep) # am--include-marker
r_depfiles_remade += $(quaternion_dep) r_depfiles_remade += $(quaternion_dep)
tools_qfcc_test_reproto_dat_SOURCES=tools/qfcc/test/reproto.r
reproto_obj=$(tools_qfcc_test_reproto_dat_SOURCES:.r=.o)
reproto_dep=$(call qcautodep,$(tools_qfcc_test_reproto_dat_SOURCES))
tools/qfcc/test/reproto.dat$(EXEEXT): $(reproto_obj) $(QFCC_DEP)
$(V_QFCCLD)$(QLINK) -o $@ $(reproto_obj)
tools/qfcc/test/reproto.run: $(qfcc_test_run_deps)
@$(top_srcdir)/tools/qfcc/test/build-run $@
include $(reproto_dep) # am--include-marker
r_depfiles_remade += $(reproto_dep)
tools_qfcc_test_return_ivar_dat_SOURCES=tools/qfcc/test/return-ivar.r tools_qfcc_test_return_ivar_dat_SOURCES=tools/qfcc/test/return-ivar.r
return_ivar_obj=$(tools_qfcc_test_return_ivar_dat_SOURCES:.r=.o) return_ivar_obj=$(tools_qfcc_test_return_ivar_dat_SOURCES:.r=.o)
return_ivar_dep=$(call qcautodep,$(tools_qfcc_test_return_ivar_dat_SOURCES)) return_ivar_dep=$(call qcautodep,$(tools_qfcc_test_return_ivar_dat_SOURCES))

View file

@ -0,0 +1,8 @@
float (entity targ) visible;
float (entity targ) visible;
int
main (void)
{
return 0; // to survive and prevail :)
}