[qfcc] Add a failing test case for compound initializers

It turns out that compound intializers break on when the nesting level
increases (eg, initializing vectors in structs in arrays).
This commit is contained in:
Bill Currie 2024-02-17 23:57:00 +09:00
parent 1b4db639af
commit 19965e7cbd
2 changed files with 74 additions and 0 deletions

View file

@ -20,6 +20,7 @@ test_progs_dat=\
tools/qfcc/test/chewed-return.dat \
tools/qfcc/test/comma-expr.dat \
tools/qfcc/test/compound.dat \
tools/qfcc/test/compoundinit.dat \
tools/qfcc/test/const-fold-int.dat \
tools/qfcc/test/deadbool.dat \
tools/qfcc/test/dealloc-nowarn.dat \
@ -265,6 +266,16 @@ tools/qfcc/test/compound.run: $(qfcc_test_run_deps)
include $(compound_dep) # am--include-marker
r_depfiles_remade += $(compound_dep)
tools_qfcc_test_compoundinit_dat_SOURCES=tools/qfcc/test/compoundinit.r
compoundinit_obj=$(tools_qfcc_test_compoundinit_dat_SOURCES:.r=.o)
compoundinit_dep=$(call qcautodep,$(tools_qfcc_test_compoundinit_dat_SOURCES))
tools/qfcc/test/compoundinit.dat$(EXEEXT): $(compoundinit_obj) $(QFCC_DEP)
$(V_QFCCLD)$(QLINK) -o $@ $(compoundinit_obj)
tools/qfcc/test/compoundinit.run: $(qfcc_test_run_deps)
@$(top_srcdir)/tools/qfcc/test/build-run $@
include $(compoundinit_dep) # am--include-marker
r_depfiles_remade += $(compoundinit_dep)
tools_qfcc_test_const_fold_int_dat_SOURCES=tools/qfcc/test/const-fold-int.r
const_fold_int_obj=$(tools_qfcc_test_const_fold_int_dat_SOURCES:.r=.o)
const_fold_int_dep=$(call qcautodep,$(tools_qfcc_test_const_fold_int_dat_SOURCES))

View file

@ -0,0 +1,63 @@
#include "test-harness.h"
typedef struct {
vector translate;
string name;
quaternion rotate;
vector scale;
int parent;
} iqmjoint_t;
static iqmjoint_t joint_data[] = {
{
.translate = { 0, 1, 0},
.name = "root",
.rotate = { 0.6, 0, 0, 0.8 },
.scale = { 1, 1, 1 },
.parent = -1,
},
{
.translate = { 0, 2, 0},
.name = "flip",
.rotate = { 0.6, 0, 0, 0.8 },
.scale = { 1, 1, 1 },
.parent = 0,
},
{
.translate = { 0, 3, 0},
.name = "flop",
.rotate = { 0.6, 0, 0, 0.8 },
.scale = { 1, 1, 1 },
.parent = 1,
},
};
int
main ()
{
if (joint_data[0].translate != '0 1 0'
|| joint_data[0].name != "root"
|| joint_data[0].rotate != '0.6 0 0 0.8'
|| joint_data[0].scale != '1 1 1'
|| joint_data[0].parent != -1) {
printf ("joint_data[0] bad\n");
return 1;
}
if (joint_data[1].translate != '0 2 0'
|| joint_data[1].name != "flip"
|| joint_data[1].rotate != '0.6 0 0 0.8'
|| joint_data[1].scale != '1 1 1'
|| joint_data[1].parent != 0) {
printf ("joint_data[1] bad\n");
return 1;
}
if (joint_data[2].translate != '0 3 0'
|| joint_data[2].name != "flop"
|| joint_data[2].rotate != '0.6 0 0 0.8'
|| joint_data[2].scale != '1 1 1'
|| joint_data[2].parent != 1) {
printf ("joint_data[2] bad\n");
return 1;
}
return 0;
}