1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00

added testprogram for issue #1374

This commit is contained in:
mrdudz 2021-01-16 16:40:58 +01:00
parent a861d84011
commit 0846219672
2 changed files with 105 additions and 0 deletions

View File

@ -109,6 +109,28 @@ $(WORKDIR)/bug1265.$1.$2.prg: bug1265.c | $(WORKDIR)
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)
# this one fails with optimizations enabled
$(WORKDIR)/bug1374.g.6502.prg: bug1374.c | $(WORKDIR)
$(if $(QUIET),echo misc/bug1374.g.6502.prg)
$(CC65) -t sim$2 -g -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)
$(WORKDIR)/bug1374.g.65c02.prg: bug1374.c | $(WORKDIR)
$(if $(QUIET),echo misc/bug1374.g.65c02.prg)
$(CC65) -t sim$2 -g -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)
$(WORKDIR)/bug1374.$1.$2.prg: bug1374.c | $(WORKDIR)
$(if $(QUIET),echo misc/bug1374.$1.$2.prg)
$(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
$(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
$(NOT) $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT) $(NULLERR)
# should compile, but then hangs in an endless loop
$(WORKDIR)/endless.$1.$2.prg: endless.c | $(WORKDIR)
$(if $(QUIET),echo misc/endless.$1.$2.prg)

83
test/misc/bug1374.c Normal file
View File

@ -0,0 +1,83 @@
/* test for bug#1374 */
#include <stdint.h>
#include <stdio.h>
static int res = 0;
int test1(void)
{
uint8_t x = 0x89;
uint8_t y = 0xab;
uint16_t z = (x << 8) | y;
printf("%x\n", z);
return (z == 0x89ab) ? 0 : 1;
}
int test1b(void)
{
uint8_t x = 0x89;
uint8_t y = 0xab;
uint16_t z = (x * 256) | y;
printf("%x\n", z);
return (z == 0x89ab) ? 0 : 1;
}
int test2(void)
{
uint16_t x = 0x8900;
uint8_t y = 0xab;
uint16_t z = x | y;
printf("%x\n", z);
return (z == 0x89ab) ? 0 : 1;
}
int test3(void)
{
uint16_t x = 0x89;
uint8_t y = 0xab;
uint16_t z = (x << 8) | y;
printf("%x\n", z);
return (z == 0x89ab) ? 0 : 1;
}
int test3b(void)
{
uint16_t x = 0x89;
uint8_t y = 0xab;
uint16_t z = (x * 256) | y;
printf("%x\n", z);
return (z == 0x89ab) ? 0 : 1;
}
int test4(void)
{
uint8_t x = 0x89;
uint16_t y = 0xab;
uint16_t z = (x << 8) | y;
printf("%x\n", z);
return (z == 0x89ab) ? 0 : 1;
}
int test4b(void)
{
uint8_t x = 0x89;
uint16_t y = 0xab;
uint16_t z = (x * 256) | y;
printf("%x\n", z);
return (z == 0x89ab) ? 0 : 1;
}
int main(void)
{
res |= test1();
res |= test2();
res |= test3();
res |= test4();
res |= test1b();
res |= test3b();
res |= test4b();
printf("res: %d\n", res);
return res;
}