mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-23 19:01:06 +00:00
Finish up alignment tests and add address cast
It turns out that initializing a local int with a pointer cast doesn't work.
This commit is contained in:
parent
a4a57b6ffd
commit
4caa875442
3 changed files with 55 additions and 1 deletions
|
@ -29,6 +29,7 @@ test_bins=\
|
|||
fail_bins=
|
||||
|
||||
test_progs_dat=\
|
||||
address-cast.dat \
|
||||
alignment.dat \
|
||||
chewed-alias.dat \
|
||||
chewed-return.dat \
|
||||
|
@ -89,6 +90,15 @@ test_harness_DEPENDENCIES= $(QFCC_TEST_DEPS)
|
|||
|
||||
r_depfiles_remade=
|
||||
|
||||
address_cast_dat_SOURCES=address-cast.r
|
||||
address_cast_obj=$(address_cast_dat_SOURCES:.r=.qfo)
|
||||
address-cast.dat$(EXEEXT): $(address_cast_obj) $(QFCC_DEP)
|
||||
$(QFCC) $(QCFLAGS) -o $@ $(address_cast_obj)
|
||||
address-cast.run: Makefile build-run
|
||||
$(srcdir)/build-run $@
|
||||
include ./$(DEPDIR)/address-cast.Qo # am--include-marker
|
||||
r_depfiles_remade += ./$(DEPDIR)/address-cast.Qo
|
||||
|
||||
alignment_dat_SOURCES=alignment.r
|
||||
alignment_obj=$(alignment_dat_SOURCES:.r=.qfo)
|
||||
alignment.dat$(EXEEXT): $(alignment_obj) $(QFCC_DEP)
|
||||
|
|
17
tools/qfcc/test/address-cast.r
Normal file
17
tools/qfcc/test/address-cast.r
Normal file
|
@ -0,0 +1,17 @@
|
|||
int a;
|
||||
double b;
|
||||
int c;
|
||||
double d;
|
||||
void printf (string fmt, ...) = #0;
|
||||
|
||||
int main()
|
||||
{
|
||||
int di = (int) &d;
|
||||
int fail = 0;
|
||||
|
||||
if (!di) {
|
||||
printf ("address cast fail: %d\n", di);
|
||||
fail |= 1;
|
||||
}
|
||||
return fail;
|
||||
}
|
|
@ -2,8 +2,35 @@ int a;
|
|||
double b;
|
||||
int c;
|
||||
double d;
|
||||
void printf (string fmt, ...) = #0;
|
||||
|
||||
int main()
|
||||
{
|
||||
return 1;
|
||||
int fail = 0;
|
||||
void *ap = &a;
|
||||
void *bp = &b;
|
||||
void *cp = &c;
|
||||
void *dp = &d;
|
||||
int aa = (int) ap;
|
||||
int ba = (int) bp;
|
||||
int ca = (int) cp;
|
||||
int da = (int) dp;
|
||||
|
||||
if (ba & 1) {
|
||||
printf ("double b is not aligned: %d\n", ba);
|
||||
fail |= 1;
|
||||
}
|
||||
if (da & 1) {
|
||||
printf ("double d is not aligned: %d\n", da);
|
||||
fail |= 1;
|
||||
}
|
||||
if (ca - aa != 1) {
|
||||
printf ("int c (%d) is not adjacant to int a (%d)\n", ca, aa);
|
||||
fail |= 1;
|
||||
}
|
||||
if (ba <= ca) {
|
||||
printf ("double b does not come after int c: %d %d\n", ba, ca);
|
||||
fail |= 1;
|
||||
}
|
||||
return fail;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue