[qfcc] Add failing test for static init

The function local static init is being treated as a non-static init
(ie, initialized each call).
This commit is contained in:
Bill Currie 2021-01-13 16:47:49 +09:00
parent 40d62e06c7
commit 1fcb16d8cf
2 changed files with 30 additions and 0 deletions

View file

@ -36,6 +36,7 @@ test_progs_dat=\
tools/qfcc/test/return-ivar.dat \
tools/qfcc/test/sendv.dat \
tools/qfcc/test/state.dat \
tools/qfcc/test/static-init.dat \
tools/qfcc/test/struct-init-param.dat \
tools/qfcc/test/struct-nil-init.dat \
tools/qfcc/test/structarray.dat \
@ -411,6 +412,16 @@ tools/qfcc/test/state.run: $(qfcc_test_run_deps)
include $(state_dep) # am--include-marker
r_depfiles_remade += $(state_dep)
tools_qfcc_test_static_init_dat_SOURCES=tools/qfcc/test/static-init.r
static_init_obj=$(tools_qfcc_test_static_init_dat_SOURCES:.r=.o)
static_init_dep=$(call qcautodep,$(tools_qfcc_test_static_init_dat_SOURCES))
tools/qfcc/test/static-init.dat$(EXEEXT): $(static_init_obj) $(QFCC_DEP)
$(V_QFCCLD)$(QLINK) -o $@ $(static_init_obj)
tools/qfcc/test/static-init.run: $(qfcc_test_run_deps)
@$(top_srcdir)/tools/qfcc/test/build-run $@
include $(static_init_dep) # am--include-marker
r_depfiles_remade += $(static_init_dep)
tools_qfcc_test_struct_init_param_dat_SOURCES=tools/qfcc/test/struct-init-param.r
struct_init_param_obj=$(tools_qfcc_test_struct_init_param_dat_SOURCES:.r=.o)
struct_init_param_dep=$(call qcautodep,$(tools_qfcc_test_struct_init_param_dat_SOURCES))

View file

@ -0,0 +1,19 @@
#include "test-harness.h"
int count_down ()
{
static int count = 2;
count--;
return count > 0;
}
int main()
{
int ret = 0;
count_down ();
if (count_down ()) {
printf ("did not reach 0\n");
ret |= 1;
}
return ret;
}