[qfcc] Clear spec.type_expr after resolving

Fixes an ICE when compiling simplex.r (thus its addition to qfcc's
tests). It still fails due to having lost the points parameter, but yet
another automated test :)
This commit is contained in:
Bill Currie 2025-01-24 15:49:49 +09:00
parent e179b10455
commit 2c96acc4f0
3 changed files with 29 additions and 0 deletions

View file

@ -720,6 +720,7 @@ spec_process (specifier_t spec, rua_ctx_t *ctx)
auto type = spec.type; // core type (int etc)
if (spec.type_expr) {
type = resolve_type (spec.type_expr, ctx);
spec.type_expr = nullptr;
}
//const type_t *type = nullptr;
// other than fields, the type list is built up by appending types

View file

@ -94,6 +94,7 @@ fail_progs_dat=
test_build_passes=\
tools/qfcc/test/calluse2.r \
tools/qfcc/test/motor.r \
tools/qfcc/test/simplex.r \
tools/qfcc/test/typeredef1.r \
tools/qfcc/test/typeredef2.r
@ -407,6 +408,9 @@ tools/qfcc/test/calluse2.run$(EXEEXT): tools/qfcc/test/calluse2.r $(qfcc_comp_ru
tools/qfcc/test/motor.run$(EXEEXT): tools/qfcc/test/motor.r $(qfcc_comp_run_deps)
@$(top_srcdir)/tools/qfcc/test/build-compile-pass-run $@ $(QFCC) $(QCFLAGS) -c $<
tools/qfcc/test/simplex.run$(EXEEXT): tools/qfcc/test/simplex.r $(qfcc_comp_run_deps)
@$(top_srcdir)/tools/qfcc/test/build-compile-pass-run $@ $(QFCC) $(QCFLAGS) -c $<
tools/qfcc/test/typeredef1.run$(EXEEXT): tools/qfcc/test/typeredef1.r $(qfcc_comp_run_deps)
@$(top_srcdir)/tools/qfcc/test/build-compile-pass-run $@ $(QFCC) $(QCFLAGS) -c $<

24
tools/qfcc/test/simplex.r Normal file
View file

@ -0,0 +1,24 @@
#pragma bug die
typedef @algebra(float(3,0,0)) VGA;
typedef struct { VGA.bvec m[3]; } tensor_t;
tensor_t
inertia_tensor (VGA.vec *points)
{
@algebra(VGA) {
static VGA.bvec basis[3] = {e23, e31, e12};
tensor_t tensor = nil;
for (int k = 0; k < 3; k++) {
VGA.bvec ten = nil;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
ten += (points[i]points[j] * basis[k]
- points[i] * basis[k] * points[j]).bvec
* ((i == j) ? 2 : 1);
}
}
tensor.m[k] = ten;
}
return tensor;
}
}