Add a test for function local static variables.

It turns out they're not getting allocated properly (they're put in the
function's locals defspace rather than near data), but fixing it proved a
little more problematic than expected, so the test is marked as XFAIL for
now to remind me to fix it.
This commit is contained in:
Bill Currie 2012-12-03 16:27:31 +09:00
parent 7412a45c65
commit 1eb3349510
2 changed files with 29 additions and 0 deletions

View file

@ -21,13 +21,18 @@ QFCC_TEST_INCS=@QFCC_TEST_INCS@
test_progs_dat=\
chewed-alias.dat \
chewed-return.dat \
func-static.dat \
deadbool.dat \
infloop.dat \
modulo.dat \
structptr.dat \
while.dat
fail_progs_dat=\
func-static.dat
TESTS=$(test_progs_dat:.dat=.run)
XFAIL_TESTS=$(fail_progs_dat:.dat=.run)
check_PROGRAMS=test-harness $(test_progs_dat)
@ -49,6 +54,13 @@ chewed-return.dat: $(chewed_return_obj) $(QFCC_DEP)
chewed-return.run: Makefile build-run
TEST_HARNESS_OPTS=--float $(srcdir)/build-run $@
func_static_dat_SOURCES=func-static.r
func_static_obj=$(func_static_dat_SOURCES:.r=.qfo)
func-static.dat: $(func_static_obj) $(QFCC_DEP)
$(QFCC) $(QCFLAGS) -o $@ $(func_static_obj)
func-static.run: Makefile build-run
$(srcdir)/build-run $@
deadbool_dat_SOURCES=deadbool.r
deadbool_obj=$(deadbool_dat_SOURCES:.r=.qfo)
deadbool.dat: $(deadbool_obj) $(QFCC_DEP)

View file

@ -0,0 +1,17 @@
int count;
void foo (void)
{
@static int x;
if (!x)
count++;
x = 1;
}
int main(void)
{
foo ();
foo ();
return count != 1;
}