Add a test for for loop declarations

I think the compiler segfaulting indicates a test failure.
This commit is contained in:
Bill Currie 2019-06-09 13:02:36 +09:00
parent 625e767684
commit d29ea55826
2 changed files with 36 additions and 0 deletions

View file

@ -32,6 +32,7 @@ test_progs_dat=\
chewed-alias.dat \
chewed-return.dat \
deadbool.dat \
fordecl.dat \
func-expr.dat \
func-static.dat \
infloop.dat \
@ -97,6 +98,15 @@ deadbool.run: Makefile build-run
include ./$(DEPDIR)/deadbool.Qo # am--include-marker
r_depfiles_remade += ./$(DEPDIR)/deadbool.Qo
fordecl_dat_SOURCES=fordecl.r
fordecl_obj=$(fordecl_dat_SOURCES:.r=.qfo)
fordecl.dat$(EXEEXT): $(fordecl_obj) $(QFCC_DEP)
$(QFCC) $(QCFLAGS) -o $@ $(fordecl_obj)
fordecl.run: Makefile build-run
$(srcdir)/build-run $@
include ./$(DEPDIR)/fordecl.Qo # am--include-marker
r_depfiles_remade += ./$(DEPDIR)/fordecl.Qo
func_expr_dat_SOURCES=func-expr.r
func_expr_obj=$(func_expr_dat_SOURCES:.r=.qfo)
func-expr.dat$(EXEEXT): $(func_expr_obj) $(QFCC_DEP)

26
tools/qfcc/test/fordecl.r Normal file
View file

@ -0,0 +1,26 @@
void printf (string fmt, ...) = #0;
int
test_fordecl ()
{
int fail = 1;
int count = 5;
for (int i = 3, j = 5; count-- > 0; ) {
i += 2;
j += 3;
}
if (i == 13 && j == 20) {
fail = 0;
}
return fail;
}
int
main ()
{
int fail = 0;
fail |= test_fordecl ();
return fail;
}