mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 06:10:56 +00:00
[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.
This commit is contained in:
parent
eacdd0d3de
commit
b6ea47dca6
3 changed files with 34 additions and 31 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
23
tools/qfcc/test/overload.r
Normal file
23
tools/qfcc/test/overload.r
Normal file
|
@ -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);
|
||||
}
|
Loading…
Reference in a new issue