From 57b2751732a06cf4bcc0a7ae855b17a5de9b0f46 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 4 Mar 2020 00:37:10 +0900 Subject: [PATCH] [qfcc] Add failing vector element address test It's an evil thing to do, but it should at least work. --- tools/qfcc/test/Makefile.am | 10 ++++++++++ tools/qfcc/test/vecaddr.r | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tools/qfcc/test/vecaddr.r diff --git a/tools/qfcc/test/Makefile.am b/tools/qfcc/test/Makefile.am index 129240670..fc6f7692b 100644 --- a/tools/qfcc/test/Makefile.am +++ b/tools/qfcc/test/Makefile.am @@ -55,6 +55,7 @@ test_progs_dat=\ structstruct.dat \ swap.dat \ triangle.dat \ + vecaddr.dat \ vecexpr.dat \ vecinit.dat \ voidfor.dat \ @@ -373,6 +374,15 @@ r_depfiles_remade += ./$(DEPDIR)/triangle.Qo #include ./$(DEPDIR)/typedef.Qo # am--include-marker #r_depfiles_remade += ./$(DEPDIR)/typedef.Qo +vecaddr_dat_SOURCES=vecaddr.r +vecaddr_obj=$(vecaddr_dat_SOURCES:.r=.qfo) +vecaddr.dat$(EXEEXT): $(vecaddr_obj) $(QFCC_DEP) + $(QFCC) $(QCFLAGS) -o $@ $(vecaddr_obj) +vecaddr.run: Makefile build-run + @$(srcdir)/build-run $@ +include ./$(DEPDIR)/vecaddr.Qo # am--include-marker +r_depfiles_remade += ./$(DEPDIR)/vecaddr.Qo + vecexpr_dat_SOURCES=vecexpr.r vecexpr_obj=$(vecexpr_dat_SOURCES:.r=.qfo) vecexpr.dat$(EXEEXT): $(vecexpr_obj) $(QFCC_DEP) diff --git a/tools/qfcc/test/vecaddr.r b/tools/qfcc/test/vecaddr.r new file mode 100644 index 000000000..323d9205c --- /dev/null +++ b/tools/qfcc/test/vecaddr.r @@ -0,0 +1,16 @@ +void printf (string fmt, ...) = #0; + +float foo (vector v, float z) +{ + return v * *(vector*)(&v.y); +} + +int +main (int argc, string *argv) +{ + vector v = [1, 2, 3]; + vector w = [2, 3, 4]; + float f; + printf ("%v %g %g %g\n", v, v*v, v*w, f=foo (v, 4)); + return f != v*w; +}