[qfcc] Add failing test for linker zero/param issue

This tests issue #6
This commit is contained in:
Bill Currie 2020-03-28 21:11:42 +09:00
parent f224eadbb8
commit 262c6a61f5
2 changed files with 57 additions and 1 deletions

View File

@ -73,7 +73,9 @@ test_progs_dat=\
vecexpr.dat \
vecinit.dat \
voidfor.dat \
while.dat
while.dat \
zerolinker.dat \
$e
fail_progs_dat=
@ -514,6 +516,15 @@ while.run: Makefile build-run
include ./$(DEPDIR)/while.Qo # am--include-marker
r_depfiles_remade += ./$(DEPDIR)/while.Qo
zerolinker_dat_SOURCES=zerolinker.r
zerolinker_obj=$(zerolinker_dat_SOURCES:.r=.qfo)
zerolinker.dat$(EXEEXT): $(zerolinker_obj) $(QFCC_DEP)
$(QFCC) $(QCFLAGS) -o $@ $(zerolinker_obj)
zerolinker.run: Makefile build-run
@$(srcdir)/build-run $@
include ./$(DEPDIR)/zerolinker.Qo # am--include-marker
r_depfiles_remade += ./$(DEPDIR)/zerolinker.Qo
$(r_depfiles_remade):
@$(MKDIR_P) $(@D)
@echo '# dummy' >$@-t && $(am__mv) $@-t $@

View File

@ -0,0 +1,45 @@
#include <types.h>
// can't link against libr.a (may not be built)
void *PR_FindGlobal (string name) = #0;
void printf (string fmt, ...) = #0;
qfot_type_encodings_t *encodings;
qfot_type_t *
next_type (qfot_type_t *type)
{
int size = type.size;
if (!size)
size = 4;
return (qfot_type_t *) ((int *) type + size);
}
int
main (void)
{
int found_param = 0;
int found_zero = 0;
qfot_type_t *type;
encodings = PR_FindGlobal (".type_encodings");
for (type = encodings.types;
((int *)type - (int *) encodings.types) < encodings.size;
type = next_type (type)) {
if (type.meta == ty_struct) {
if (type.t.strct.tag == "tag @param") {
found_param = 1;
}
if (type.t.strct.tag == "tag @zero") {
found_zero = 1;
}
}
}
if (!(found_param && found_zero)) {
printf ("missing struct: param: %d zero:%d\n",
found_param, found_zero);
return 1;
}
return 0;
}