[qfcc] Add some tests for postop--

Interestingly, intval-- works properly, but unsignedval-- does not (test
case fails). This is why menus blow up when opening the load/save
sub-menu.
This commit is contained in:
Bill Currie 2023-12-20 21:30:02 +09:00
parent aed637e4de
commit 54839db826
3 changed files with 39 additions and 0 deletions

View file

@ -70,6 +70,7 @@ test_progs_dat=\
tools/qfcc/test/twice-called.dat \
tools/qfcc/test/typedef.dat \
tools/qfcc/test/typelinker.dat \
tools/qfcc/test/upostop.dat \
tools/qfcc/test/unaryminus.dat \
tools/qfcc/test/vecaddr.dat \
tools/qfcc/test/vecexpr.dat \
@ -812,6 +813,16 @@ tools/qfcc/test/typelinker.run: $(qfcc_test_run_deps)
include $(typelinker_dep) # am--include-marker
r_depfiles_remade += $(typelinker_dep)
tools_qfcc_test_upostop_dat_SOURCES=tools/qfcc/test/upostop.r
upostop_obj=$(tools_qfcc_test_upostop_dat_SOURCES:.r=.o)
upostop_dep=$(call qcautodep,$(tools_qfcc_test_upostop_dat_SOURCES))
tools/qfcc/test/upostop.dat$(EXEEXT): $(upostop_obj) $(QFCC_DEP)
$(V_QFCCLD)$(QLINK) -o $@ $(upostop_obj)
tools/qfcc/test/upostop.run: $(qfcc_test_run_deps)
@$(top_srcdir)/tools/qfcc/test/build-run $@
include $(upostop_dep) # am--include-marker
r_depfiles_remade += $(upostop_dep)
tools_qfcc_test_unaryminus_dat_SOURCES=tools/qfcc/test/unaryminus.r
unaryminus_obj=$(tools_qfcc_test_unaryminus_dat_SOURCES:.r=.o)
unaryminus_dep=$(call qcautodep,$(tools_qfcc_test_unaryminus_dat_SOURCES))

View file

@ -10,10 +10,21 @@ int array_index (void)
return i == 3 && !(array[0] | array[1] | array[2]);
}
int iter_check (int count)
{
int i = count;
int iters = 0;
while (i-- > 0) {
iters++;
}
return iters == count;
}
int
main ()
{
int ret = 0;
ret |= !array_index ();
ret |= !iter_check (1);
return ret;
}

17
tools/qfcc/test/upostop.r Normal file
View file

@ -0,0 +1,17 @@
int iter_check (unsigned count)
{
unsigned i = count;
int iters = 0;
while (i-- > 0) {
iters++;
}
return iters == count;
}
int
main ()
{
int ret = 0;
ret |= !iter_check (1);
return ret;
}