From b6ea47dca690e345e75ca4917db35df471237220 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 28 Mar 2020 18:58:08 +0900 Subject: [PATCH] [qfcc] Add failing function overload test This is a bit of a weird one because it's a combination of the aliasing code and mixing C prototypes with QuakeC function definitions, and the function type rebuilding in qc-parse.y not being very "consistent" in its abuse of the type system. --- tools/qfcc/test/Makefile.am | 12 +++++++++++- tools/qfcc/test/old/overload.r | 30 ------------------------------ tools/qfcc/test/overload.r | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+), 31 deletions(-) delete mode 100644 tools/qfcc/test/old/overload.r create mode 100644 tools/qfcc/test/overload.r diff --git a/tools/qfcc/test/Makefile.am b/tools/qfcc/test/Makefile.am index fe78065d7..73528545d 100644 --- a/tools/qfcc/test/Makefile.am +++ b/tools/qfcc/test/Makefile.am @@ -54,6 +54,7 @@ test_progs_dat=\ methodparams.dat \ modulo.dat \ nilparamret.dat \ + overload.dat \ paramret.dat \ quaternion.dat \ return-ivar.dat \ @@ -333,6 +334,15 @@ nilparamret.run: Makefile build-run include ./$(DEPDIR)/nilparamret.Qo # am--include-marker r_depfiles_remade += ./$(DEPDIR)/nilparamret.Qo +overload_dat_SOURCES=overload.r +overload_obj=$(overload_dat_SOURCES:.r=.qfo) +overload.dat$(EXEEXT): $(overload_obj) $(QFCC_DEP) + $(QFCC) $(QCFLAGS) -o $@ $(overload_obj) +overload.run: Makefile build-run + @$(srcdir)/build-run $@ +include ./$(DEPDIR)/overload.Qo # am--include-marker +r_depfiles_remade += ./$(DEPDIR)/overload.Qo + paramret_dat_SOURCES=paramret.r paramret_obj=$(paramret_dat_SOURCES:.r=.qfo) paramret.dat$(EXEEXT): $(paramret_obj) $(QFCC_DEP) @@ -512,4 +522,4 @@ $(r_depfiles_remade): am--depfiles: $(am__depfiles_remade) $(r_depfiles_remade) EXTRA_DIST= test-bi.h build-run test-defspace.h -CLEANFILES= *.dat *.sym *.qfo *.run *.frame +CLEANFILES= *.dat *.sym *.qfo *.run *.frame *.log *.trs diff --git a/tools/qfcc/test/old/overload.r b/tools/qfcc/test/old/overload.r deleted file mode 100644 index 60bd5cf46..000000000 --- a/tools/qfcc/test/old/overload.r +++ /dev/null @@ -1,30 +0,0 @@ -//integer foo; -//typedef integer foo; -//integer (void) foo = #0; -//integer (bag); -//.integer (sack); -//.integer (float sack)x; -//integer *bar, baz; -//integer snafu(void) -//{ -//} -//integer [8]blah; - -@overload void func (integer a, integer b, integer c); -@overload void func (integer a, integer b); -@overload void func (integer a, ...); -//@overload void func (integer a, integer b, ...); -@overload void func (string y); -//@overload void func (...); -void func (integer x) -{ -// func (""); -} -void func (string y) -{ -// func (0.0); -// func (0, 0.0); -// func (0, 0, 0.0); - func (0.0, ""); -// func (0, 0, 0, 0, 0.0); -} diff --git a/tools/qfcc/test/overload.r b/tools/qfcc/test/overload.r new file mode 100644 index 000000000..97c77bbdf --- /dev/null +++ b/tools/qfcc/test/overload.r @@ -0,0 +1,23 @@ +typedef enum { + NO = 0, + YES +} BOOL; + +@extern BOOL sel_is_mapped (SEL aSel); +BOOL (SEL aSel) sel_is_mapped = #0; + +@overload int foo(int x) +{ + return 1; +} + +@overload int foo(float x) +{ + return 2; +} + +int main() +{ + //FIXME fails on implicit cast of double to float + return !(foo(5) == 1 && foo (5.0f) == 2); +}