Add a test for writes to global vars in a loop.

This commit is contained in:
Bill Currie 2012-11-24 14:53:45 +09:00
parent bdafdad0d5
commit 2478b053de
3 changed files with 38 additions and 1 deletions

View file

@ -18,7 +18,7 @@ QFCC_TEST_LIBS=@QFCC_TEST_LIBS@
QFCC_TEST_DEPS=@QFCC_TEST_DEPS@
QFCC_TEST_INCS=@QFCC_TEST_INCS@
test_progs_dat=modulo.dat structptr.dat while.dat
test_progs_dat=infloop.dat modulo.dat structptr.dat while.dat
TESTS=$(test_progs_dat:.dat=.run)
@ -28,6 +28,13 @@ test_harness_SOURCES= test-bi.c test-harness.c
test_harness_LDADD= $(QFCC_TEST_LIBS)
test_harness_DEPENDENCIES= $(QFCC_TEST_DEPS)
infloop_dat_SOURCES=infloop.r
infloop_obj=$(infloop_dat_SOURCES:.r=.qfo)
infloop.dat: $(infloop_obj) $(QFCC_DEP)
$(QFCC) $(QCFLAGS) -o $@ $(infloop_obj)
infloop.run: Makefile build-run
$(srcdir)/build-run $@
modulo_dat_SOURCES=modulo.r
modulo_obj=$(modulo_dat_SOURCES:.r=.qfo)
modulo.dat: $(modulo_obj) $(QFCC_DEP)

23
tools/qfcc/test/infloop.r Normal file
View file

@ -0,0 +1,23 @@
void exit (int code) = #0;
int foo;
int calc_foo (void)
{
return 1;
}
void check_foo (void)
{
if (foo)
exit (0);
exit (1);
}
int main ()
{
while (1) {
foo = calc_foo ();
check_foo ();
}
}

View file

@ -71,10 +71,17 @@ bi_strerror (progs_t *pr)
RETURN_STRING (pr, strerror (err));
}
static void
bi_exit (progs_t *pr)
{
exit (P_INT (pr, 0));
}
static builtin_t builtins[] = {
{"printf", bi_printf, -1},
{"errno", bi_errno, -1},
{"strerror", bi_strerror, -1},
{"exit", bi_exit, -1},
{0}
};