Merge branch 'master' into StaticConst
This commit is contained in:
@@ -8,23 +8,22 @@ ifdef CMD_EXE
|
||||
EXE = .exe
|
||||
MKDIR = mkdir $(subst /,\,$1)
|
||||
RMDIR = -rmdir /s /q $(subst /,\,$1)
|
||||
DEL = del /f $(subst /,\,$1)
|
||||
else
|
||||
EXE =
|
||||
MKDIR = mkdir -p $1
|
||||
RMDIR = $(RM) -r $1
|
||||
DEL = $(RM) $1
|
||||
endif
|
||||
|
||||
ifdef QUIET
|
||||
.SILENT:
|
||||
endif
|
||||
|
||||
CL65 := $(if $(wildcard ../../bin/cl65*),../../bin/cl65,cl65)
|
||||
CA65 := $(if $(wildcard ../../bin/ca65*),../../bin/ca65,ca65)
|
||||
LD65 := $(if $(wildcard ../../bin/ld65*),../../bin/ld65,ld65)
|
||||
|
||||
WORKDIR = ../../testwrk/asm
|
||||
|
||||
DIFF = $(WORKDIR)/isequal$(EXE)
|
||||
ISEQUAL = $(WORKDIR)/isequal$(EXE)
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -O2
|
||||
@@ -44,29 +43,28 @@ all: $(OPCODE_BINS) $(CPUDETECT_BINS)
|
||||
$(WORKDIR):
|
||||
$(call MKDIR,$(WORKDIR))
|
||||
|
||||
$(DIFF): ../isequal.c | $(WORKDIR)
|
||||
$(ISEQUAL): ../isequal.c | $(WORKDIR)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
define OPCODE_template
|
||||
|
||||
$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(DIFF)
|
||||
$(WORKDIR)/$1-opcodes.bin: $1-opcodes.s $(ISEQUAL)
|
||||
$(if $(QUIET),echo asm/$1-opcodes.bin)
|
||||
$(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $$@ $$<
|
||||
$(DIFF) $$@ $1-opcodes.ref
|
||||
$(CA65) --cpu $1 -t none -l $(WORKDIR)/$1-opcodes.lst -o $(WORKDIR)/$1-opcodes.o $$<
|
||||
$(LD65) -t none -o $$@ $(WORKDIR)/$1-opcodes.o none.lib
|
||||
$(ISEQUAL) $$@ $1-opcodes.ref
|
||||
|
||||
endef # OPCODE_template
|
||||
|
||||
$(foreach cpu,$(OPCODE_CPUS),$(eval $(call OPCODE_template,$(cpu))))
|
||||
|
||||
# cpudetect.o is written by multiple rules
|
||||
.NOTPARALLEL:
|
||||
|
||||
define CPUDETECT_template
|
||||
|
||||
$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(DIFF)
|
||||
$(WORKDIR)/$1-cpudetect.bin: cpudetect.s $(ISEQUAL)
|
||||
$(if $(QUIET),echo asm/$1-cpudetect.bin)
|
||||
$(CL65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $$@ $$<
|
||||
$(DIFF) $$@ $1-cpudetect.ref
|
||||
$(CA65) --cpu $1 -t none -l $(WORKDIR)/$1-cpudetect.lst -o $(WORKDIR)/$1-cpudetect.o $$<
|
||||
$(LD65) -t none -o $$@ $(WORKDIR)/$1-cpudetect.o none.lib
|
||||
$(ISEQUAL) $$@ $1-cpudetect.ref
|
||||
|
||||
endef # CPUDETECT_template
|
||||
|
||||
@@ -74,4 +72,3 @@ $(foreach cpu,$(CPUDETECT_CPUS),$(eval $(call CPUDETECT_template,$(cpu))))
|
||||
|
||||
clean:
|
||||
@$(call RMDIR,$(WORKDIR))
|
||||
@$(call DEL,$(OPCODE_REFS:.ref=.o) cpudetect.o)
|
||||
|
||||
@@ -8,12 +8,10 @@ ifdef CMD_EXE
|
||||
EXE = .exe
|
||||
MKDIR = mkdir $(subst /,\,$1)
|
||||
RMDIR = -rmdir /s /q $(subst /,\,$1)
|
||||
DEL = del /f $(subst /,\,$1)
|
||||
else
|
||||
EXE =
|
||||
MKDIR = mkdir -p $1
|
||||
RMDIR = $(RM) -r $1
|
||||
DEL = $(RM) $1
|
||||
endif
|
||||
|
||||
ifdef QUIET
|
||||
@@ -25,7 +23,7 @@ DA65 := $(if $(wildcard ../../bin/da65*),../../bin/da65,da65)
|
||||
|
||||
WORKDIR = ../../testwrk/dasm
|
||||
|
||||
DIFF = $(WORKDIR)/isequal$(EXE)
|
||||
ISEQUAL = $(WORKDIR)/isequal$(EXE)
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -O2
|
||||
@@ -44,7 +42,7 @@ all: $(BINS)
|
||||
$(WORKDIR):
|
||||
$(call MKDIR,$(WORKDIR))
|
||||
|
||||
$(DIFF): ../isequal.c | $(WORKDIR)
|
||||
$(ISEQUAL): ../isequal.c | $(WORKDIR)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
define DISASS_template
|
||||
@@ -55,10 +53,10 @@ $(WORKDIR)/$1-disass.bin: $1-disass.s | $(WORKDIR)
|
||||
$(WORKDIR)/$1-reass.s: $(WORKDIR)/$1-disass.bin
|
||||
$(DA65) --cpu $1 $(START) -o $$@ $$<
|
||||
|
||||
$(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(DIFF)
|
||||
$(WORKDIR)/$1-reass.bin: $(WORKDIR)/$1-reass.s $(ISEQUAL)
|
||||
$(if $(QUIET),echo dasm/$1-reass.bin)
|
||||
$(CL65) --cpu $1 -t none $(START) -o $$@ $$<
|
||||
$(DIFF) $$@ $(WORKDIR)/$1-disass.bin
|
||||
$(ISEQUAL) $$@ $(WORKDIR)/$1-disass.bin
|
||||
|
||||
endef # DISASS_template
|
||||
|
||||
@@ -66,4 +64,3 @@ $(foreach cpu,$(CPUS),$(eval $(call DISASS_template,$(cpu))))
|
||||
|
||||
clean:
|
||||
@$(call RMDIR,$(WORKDIR))
|
||||
@$(call DEL,$(SOURCES:.s=.o))
|
||||
|
||||
@@ -23,23 +23,23 @@ ifdef QUIET
|
||||
NULLERR = 2>$(NULLDEV)
|
||||
endif
|
||||
|
||||
CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
|
||||
CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
|
||||
|
||||
WORKDIR = ../../testwrk/err
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
SOURCES := $(wildcard *.c)
|
||||
TESTS = $(patsubst %.c,$(WORKDIR)/%.prg,$(SOURCES))
|
||||
TESTS = $(patsubst %.c,$(WORKDIR)/%.s,$(SOURCES))
|
||||
|
||||
all: $(TESTS)
|
||||
|
||||
$(WORKDIR):
|
||||
$(call MKDIR,$(WORKDIR))
|
||||
|
||||
$(WORKDIR)/%.prg: %.c | $(WORKDIR)
|
||||
$(WORKDIR)/%.s: %.c | $(WORKDIR)
|
||||
$(if $(QUIET),echo err/$*.s)
|
||||
$(NOT) $(CL65) -o $@ $< $(NULLERR)
|
||||
$(NOT) $(CC65) -o $@ $< $(NULLERR)
|
||||
|
||||
clean:
|
||||
@$(call RMDIR,$(WORKDIR))
|
||||
|
||||
52
test/err/bug1211-ice-move-refs-1.c
Normal file
52
test/err/bug1211-ice-move-refs-1.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright 2020 The cc65 Authors
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
Test of indirect goto with label merge ICE.
|
||||
https://github.com/cc65/cc65/issues/1211
|
||||
This should compile and should be moved to tests/val/ when the bug is fixed.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* When operating correctly, f(0) = 31 and f(1) = 41. */
|
||||
int f (int x)
|
||||
{
|
||||
static const void *const labels[] = {&&L0, &&L1};
|
||||
goto *labels[x];
|
||||
L0: if (labels[0] != labels[1]) return 31;
|
||||
else return 13;
|
||||
L1: return 41;
|
||||
}
|
||||
|
||||
static unsigned char failures = 0;
|
||||
|
||||
int main (void)
|
||||
{
|
||||
if (f (0) != 31) failures++;
|
||||
|
||||
if (failures == 0) {
|
||||
printf ("PASS\n");
|
||||
} else {
|
||||
printf ("FAIL\n");
|
||||
}
|
||||
|
||||
return failures;
|
||||
}
|
||||
51
test/err/bug1211-ice-move-refs-2.c
Normal file
51
test/err/bug1211-ice-move-refs-2.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Copyright 2020 The cc65 Authors
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
Test of indirect goto with label merge ICE.
|
||||
https://github.com/cc65/cc65/issues/1211
|
||||
This should compile and should be moved to tests/val/ when the bug is fixed.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* When operating correctly, this returns 0. */
|
||||
int f (void)
|
||||
{
|
||||
static const void *const x[2] = {&&L0, &&L1};
|
||||
goto *x[0];
|
||||
L0:
|
||||
L1: return 0;
|
||||
}
|
||||
|
||||
static unsigned char failures = 0;
|
||||
|
||||
int main (void)
|
||||
{
|
||||
if (f () != 0) failures++;
|
||||
|
||||
if (failures == 0) {
|
||||
printf ("PASS\n");
|
||||
} else {
|
||||
printf ("FAIL\n");
|
||||
}
|
||||
|
||||
return failures;
|
||||
}
|
||||
@@ -11,7 +11,6 @@ ifdef CMD_EXE
|
||||
NULLDEV = nul:
|
||||
MKDIR = mkdir $(subst /,\,$1)
|
||||
RMDIR = -rmdir /s /q $(subst /,\,$1)
|
||||
DEL = del /f $(subst /,\,$1)
|
||||
else
|
||||
S = /
|
||||
NOT = !
|
||||
@@ -19,7 +18,6 @@ else
|
||||
NULLDEV = /dev/null
|
||||
MKDIR = mkdir -p $1
|
||||
RMDIR = $(RM) -r $1
|
||||
DEL = $(RM) $1
|
||||
endif
|
||||
|
||||
ifdef QUIET
|
||||
@@ -30,14 +28,16 @@ endif
|
||||
|
||||
SIM65FLAGS = -x 200000000
|
||||
|
||||
CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
|
||||
CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
|
||||
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
|
||||
LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
|
||||
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
|
||||
|
||||
WORKDIR = ..$S..$Stestwrk$Smisc
|
||||
|
||||
OPTIONS = g O Os Osi Osir Osr Oi Oir Or
|
||||
|
||||
DIFF = $(WORKDIR)$Sisequal$(EXE)
|
||||
ISEQUAL = $(WORKDIR)$Sisequal$(EXE)
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -O2
|
||||
@@ -50,15 +50,10 @@ TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.
|
||||
|
||||
all: $(TESTS)
|
||||
|
||||
# The same input file is processed with different cl65 args,
|
||||
# but cl65 uses the input file name to make the temp file name,
|
||||
# and they stomp each other.
|
||||
.NOTPARALLEL:
|
||||
|
||||
$(WORKDIR):
|
||||
$(call MKDIR,$(WORKDIR))
|
||||
|
||||
$(DIFF): ../isequal.c | $(WORKDIR)
|
||||
$(ISEQUAL): ../isequal.c | $(WORKDIR)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
define PRG_template
|
||||
@@ -67,44 +62,65 @@ define PRG_template
|
||||
$(WORKDIR)/bug760.$1.$2.prg: bug760.c | $(WORKDIR)
|
||||
@echo "FIXME: " $$@ "currently does not compile."
|
||||
$(if $(QUIET),echo misc/bug760.$1.$2.prg)
|
||||
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
|
||||
$(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
|
||||
|
||||
# should compile, but gives an error
|
||||
$(WORKDIR)/bug1209-ind-goto-rev.$1.$2.prg: bug1209-ind-goto-rev.c | $(WORKDIR)
|
||||
@echo "FIXME: " $$@ "currently does not compile."
|
||||
$(if $(QUIET),echo misc/bug1209-ind-goto-rev.$1.$2.prg)
|
||||
$(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
|
||||
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
|
||||
$(NOT) $(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
|
||||
|
||||
# should compile, but gives an error
|
||||
$(WORKDIR)/bug1209-ind-goto-rev-2.$1.$2.prg: bug1209-ind-goto-rev-2.c | $(WORKDIR)
|
||||
@echo "FIXME: " $$@ "currently does not compile."
|
||||
$(if $(QUIET),echo misc/bug1209-ind-goto-rev-2.$1.$2.prg)
|
||||
$(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
|
||||
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
|
||||
$(NOT) $(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
|
||||
|
||||
# should compile, but gives an error
|
||||
$(WORKDIR)/bug1209-ind-goto-rev-3.$1.$2.prg: bug1209-ind-goto-rev-3.c | $(WORKDIR)
|
||||
@echo "FIXME: " $$@ "currently does not compile."
|
||||
$(if $(QUIET),echo misc/bug1209-ind-goto-rev-3.$1.$2.prg)
|
||||
$(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLERR)
|
||||
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
|
||||
$(NOT) $(LD65) -t sim$2 -o $$@ $$(@:.prg=.o) sim$2.lib $(NULLERR)
|
||||
|
||||
# should compile, but gives an error
|
||||
$(WORKDIR)/pptest2.$1.$2.prg: pptest2.c | $(WORKDIR)
|
||||
@echo "FIXME: " $$@ "currently does not compile."
|
||||
$(if $(QUIET),echo misc/pptest2.$1.$2.prg)
|
||||
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
|
||||
|
||||
# this should fail to compile, because there are errors in the code
|
||||
# instead, the compiler crashes
|
||||
$(WORKDIR)/bug1113.$1.$2.prg: bug1113.c | $(WORKDIR)
|
||||
@echo "FIXME: " $$@ "compiler crashes but should give an error."
|
||||
$(if $(QUIET),echo misc/bug1113.$1.$2.prg)
|
||||
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
|
||||
$(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(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)
|
||||
$(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
|
||||
$(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)
|
||||
|
||||
# these need reference data that can't be generated by a host-compiled program,
|
||||
# in a useful way
|
||||
$(WORKDIR)/limits.$1.$2.prg: limits.c $(DIFF) | $(WORKDIR)
|
||||
$(WORKDIR)/limits.$1.$2.prg: limits.c $(ISEQUAL) | $(WORKDIR)
|
||||
$(if $(QUIET),echo misc/limits.$1.$2.prg)
|
||||
$(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
|
||||
$(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)
|
||||
$(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.$2.out
|
||||
$(DIFF) $(WORKDIR)/limits.$1.$2.out limits.ref
|
||||
$(ISEQUAL) $(WORKDIR)/limits.$1.$2.out limits.ref
|
||||
|
||||
$(WORKDIR)/goto.$1.$2.prg: goto.c $(DIFF) | $(WORKDIR)
|
||||
$(WORKDIR)/goto.$1.$2.prg: goto.c $(ISEQUAL) | $(WORKDIR)
|
||||
$(if $(QUIET),echo misc/goto.$1.$2.prg)
|
||||
$(CL65) -t sim$2 -$1 -o $$@ $$< 2>$(WORKDIR)/goto.$1.$2.out
|
||||
$(DIFF) $(WORKDIR)/goto.$1.$2.out goto.ref
|
||||
$(CC65) -t sim$2 -$1 -o $$@ $$< 2>$(WORKDIR)/goto.$1.$2.out
|
||||
$(ISEQUAL) $(WORKDIR)/goto.$1.$2.out goto.ref
|
||||
|
||||
# the rest are tests that fail currently for one reason or another
|
||||
$(WORKDIR)/sitest.$1.$2.prg: sitest.c | $(WORKDIR)
|
||||
@echo "FIXME: " $$@ "currently does not compile."
|
||||
$(NOT) $(CL65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
|
||||
$(NOT) $(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLERR)
|
||||
# $(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
|
||||
|
||||
endef # PRG_template
|
||||
@@ -114,4 +130,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
|
||||
|
||||
clean:
|
||||
@$(call RMDIR,$(WORKDIR))
|
||||
@$(call DEL,$(SOURCES:.c=.o))
|
||||
|
||||
54
test/misc/bug1209-ind-goto-rev-2.c
Normal file
54
test/misc/bug1209-ind-goto-rev-2.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
Copyright 2020 The cc65 Authors
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
Test of indirect goto without dynamic labels and order label def, label ref, goto.
|
||||
https://github.com/cc65/cc65/issues/1209
|
||||
This should compile and should be moved to tests/val/ when the bug is fixed.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* When operating correctly, this returns 0. */
|
||||
static unsigned char y = 0;
|
||||
int f (void) {
|
||||
L: if (y) return 0;
|
||||
{
|
||||
static const void *const x[1] = {&&L};
|
||||
y = 1;
|
||||
goto *x[0];
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned char failures = 0;
|
||||
|
||||
int main (void)
|
||||
{
|
||||
if (f () != 0) failures++;
|
||||
|
||||
if (failures == 0) {
|
||||
printf ("PASS\n");
|
||||
} else {
|
||||
printf ("FAIL\n");
|
||||
}
|
||||
|
||||
return failures;
|
||||
}
|
||||
52
test/misc/bug1209-ind-goto-rev-3.c
Normal file
52
test/misc/bug1209-ind-goto-rev-3.c
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright 2020 The cc65 Authors
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
Test of indirect goto without dynamic labels and order label ref, label def, goto.
|
||||
https://github.com/cc65/cc65/issues/1209
|
||||
This should compile and should be moved to tests/val/ when the bug is fixed.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* When operating correctly, this returns 0. */
|
||||
static unsigned char y = 0;
|
||||
int f (void) {
|
||||
static const void *const x[1] = {&&L};
|
||||
L: if (y) return 0;
|
||||
y = 1;
|
||||
goto *x[0];
|
||||
}
|
||||
|
||||
static unsigned char failures = 0;
|
||||
|
||||
int main (void)
|
||||
{
|
||||
if (f () != 0) failures++;
|
||||
|
||||
if (failures == 0) {
|
||||
printf ("PASS\n");
|
||||
} else {
|
||||
printf ("FAIL\n");
|
||||
}
|
||||
|
||||
return failures;
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
Tests of indirect goto with the label before the goto.
|
||||
Test of indirect goto with dynamic labels and order label def, label ref, goto.
|
||||
https://github.com/cc65/cc65/issues/1209
|
||||
This should compile and should be moved to tests/val/ when the bug is fixed.
|
||||
*/
|
||||
@@ -32,7 +32,7 @@ int f (void)
|
||||
{
|
||||
static void *x[1];
|
||||
/* Define the label before referencing it with indirect label syntax. */
|
||||
L: if (x[0] != 0) return 0;
|
||||
L: if (x[0] != 0) return 0;
|
||||
x[0] = &&L;
|
||||
goto *x[0];
|
||||
}
|
||||
@@ -46,7 +46,7 @@ int main (void)
|
||||
if (failures == 0) {
|
||||
printf ("PASS\n");
|
||||
} else {
|
||||
printf ("FAIL: %d failures\n", failures);
|
||||
printf ("FAIL\n");
|
||||
}
|
||||
|
||||
return failures;
|
||||
@@ -11,14 +11,12 @@ ifdef CMD_EXE
|
||||
NULLDEV = nul:
|
||||
MKDIR = mkdir $(subst /,\,$1)
|
||||
RMDIR = -rmdir /s /q $(subst /,\,$1)
|
||||
DEL = del /f $(subst /,\,$1)
|
||||
else
|
||||
S = /
|
||||
EXE =
|
||||
NULLDEV = /dev/null
|
||||
MKDIR = mkdir -p $1
|
||||
RMDIR = $(RM) -r $1
|
||||
DEL = $(RM) $1
|
||||
endif
|
||||
|
||||
ifdef QUIET
|
||||
@@ -28,14 +26,16 @@ endif
|
||||
|
||||
SIM65FLAGS = -x 200000000
|
||||
|
||||
CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
|
||||
CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
|
||||
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
|
||||
LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
|
||||
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
|
||||
|
||||
WORKDIR = ..$S..$Stestwrk$Sref
|
||||
|
||||
OPTIONS = g O Os Osi Osir Osr Oi Oir Or
|
||||
|
||||
DIFF = $(WORKDIR)$Sisequal$(EXE)
|
||||
ISEQUAL = $(WORKDIR)$Sisequal$(EXE)
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -O2 -Wall -W -Wextra -funsigned-char -fwrapv -fno-strict-overflow
|
||||
@@ -57,7 +57,7 @@ $(WORKDIR)/%.ref: %.c | $(WORKDIR)
|
||||
$(CC) $(CFLAGS) -o $(WORKDIR)/$*.host $< $(NULLERR)
|
||||
$(WORKDIR)$S$*.host > $@
|
||||
|
||||
$(DIFF): ../isequal.c | $(WORKDIR)
|
||||
$(ISEQUAL): ../isequal.c | $(WORKDIR)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
# "yaccdbg.c" includes "yacc.c".
|
||||
@@ -68,11 +68,13 @@ $(WORKDIR)/yaccdbg.%.prg: yacc.c
|
||||
|
||||
define PRG_template
|
||||
|
||||
$(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(DIFF)
|
||||
$(WORKDIR)/%.$1.$2.prg: %.c $(WORKDIR)/%.ref $(ISEQUAL)
|
||||
$(if $(QUIET),echo ref/$$*.$1.$2.prg)
|
||||
$(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR)
|
||||
$(CC65) -t sim$2 $$(CC65FLAGS) -$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)
|
||||
$(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/$$*.$1.$2.out
|
||||
$(DIFF) $(WORKDIR)/$$*.$1.$2.out $(WORKDIR)/$$*.ref
|
||||
$(ISEQUAL) $(WORKDIR)/$$*.$1.$2.out $(WORKDIR)/$$*.ref
|
||||
|
||||
endef # PRG_template
|
||||
|
||||
@@ -81,4 +83,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
|
||||
|
||||
clean:
|
||||
@$(call RMDIR,$(WORKDIR))
|
||||
@$(call DEL,$(SOURCES:.c=.o))
|
||||
|
||||
@@ -10,14 +10,12 @@ ifdef CMD_EXE
|
||||
NULLDEV = nul:
|
||||
MKDIR = mkdir $(subst /,\,$1)
|
||||
RMDIR = -rmdir /s /q $(subst /,\,$1)
|
||||
DEL = del /f $(subst /,\,$1)
|
||||
else
|
||||
S = /
|
||||
NOT = !
|
||||
NULLDEV = /dev/null
|
||||
MKDIR = mkdir -p $1
|
||||
RMDIR = $(RM) -r $1
|
||||
DEL = $(RM) $1
|
||||
endif
|
||||
|
||||
ifdef QUIET
|
||||
@@ -28,7 +26,9 @@ endif
|
||||
|
||||
SIM65FLAGS = -x 200000000
|
||||
|
||||
CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
|
||||
CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
|
||||
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
|
||||
LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
|
||||
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
|
||||
|
||||
WORKDIR = ../../testwrk/val
|
||||
@@ -50,7 +50,9 @@ define PRG_template
|
||||
|
||||
$(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR)
|
||||
$(if $(QUIET),echo val/$$*.$1.$2.prg)
|
||||
$(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR)
|
||||
$(CC65) -t sim$2 $$(CC65FLAGS) -$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)
|
||||
|
||||
endef # PRG_template
|
||||
@@ -60,4 +62,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
|
||||
|
||||
clean:
|
||||
@$(call RMDIR,$(WORKDIR))
|
||||
@$(call DEL,$(SOURCES:.c=.o))
|
||||
|
||||
@@ -9,13 +9,11 @@ ifdef CMD_EXE
|
||||
NULLDEV = nul:
|
||||
MKDIR = mkdir $(subst /,\,$1)
|
||||
RMDIR = -rmdir /s /q $(subst /,\,$1)
|
||||
DEL = del /f $(subst /,\,$1)
|
||||
else
|
||||
S = /
|
||||
NULLDEV = /dev/null
|
||||
MKDIR = mkdir -p $1
|
||||
RMDIR = $(RM) -r $1
|
||||
DEL = $(RM) $1
|
||||
endif
|
||||
|
||||
ifdef QUIET
|
||||
@@ -26,7 +24,9 @@ endif
|
||||
|
||||
SIM65FLAGS = -x 5000000000
|
||||
|
||||
CL65 := $(if $(wildcard ../../bin/cl65*),..$S..$Sbin$Scl65,cl65)
|
||||
CC65 := $(if $(wildcard ../../bin/cc65*),..$S..$Sbin$Scc65,cc65)
|
||||
CA65 := $(if $(wildcard ../../bin/ca65*),..$S..$Sbin$Sca65,ca65)
|
||||
LD65 := $(if $(wildcard ../../bin/ld65*),..$S..$Sbin$Sld65,ld65)
|
||||
SIM65 := $(if $(wildcard ../../bin/sim65*),..$S..$Sbin$Ssim65,sim65)
|
||||
|
||||
WORKDIR = ../../testwrk/val
|
||||
@@ -41,11 +41,6 @@ TESTS += $(foreach option,$(OPTIONS),$(SOURCES:%.c=$(WORKDIR)/%.$(option).65c02.
|
||||
|
||||
all: $(TESTS)
|
||||
|
||||
# The same input file is processed with different cl65 args,
|
||||
# but cl65 uses the input file name to make the temp file name,
|
||||
# and they stomp each other.
|
||||
.NOTPARALLEL:
|
||||
|
||||
$(WORKDIR):
|
||||
$(call MKDIR,$(WORKDIR))
|
||||
|
||||
@@ -53,7 +48,9 @@ define PRG_template
|
||||
|
||||
$(WORKDIR)/%.$1.$2.prg: %.c | $(WORKDIR)
|
||||
$(if $(QUIET),echo val/$$*.$1.$2.prg)
|
||||
$(CL65) -t sim$2 $$(CC65FLAGS) -$1 -o $$@ $$< $(NULLERR)
|
||||
$(CC65) -t sim$2 $$(CC65FLAGS) -$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)
|
||||
$(SIM65) $(SIM65FLAGS) $$@ $(NULLOUT)
|
||||
|
||||
endef # PRG_template
|
||||
@@ -63,4 +60,3 @@ $(foreach option,$(OPTIONS),$(eval $(call PRG_template,$(option),65c02)))
|
||||
|
||||
clean:
|
||||
@$(call RMDIR,$(WORKDIR))
|
||||
@$(call DEL,$(SOURCES:.c=.o))
|
||||
|
||||
25
test/val/bug1201.c
Normal file
25
test/val/bug1201.c
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
/* bug #1201 - The unary operators +, - and ~ should do integer promote on the result types. */
|
||||
|
||||
char a;
|
||||
short b;
|
||||
int c;
|
||||
long d;
|
||||
enum E {
|
||||
Z
|
||||
} e;
|
||||
struct S {
|
||||
int a : 1;
|
||||
} f;
|
||||
|
||||
_Static_assert(sizeof(+a) == sizeof(int), "Result type should be int");
|
||||
_Static_assert(sizeof(+b) == sizeof(int), "Result type should be int");
|
||||
_Static_assert(sizeof(+c) == sizeof(int), "Result type should be int");
|
||||
_Static_assert(sizeof(+d) == sizeof(long), "Result type should be long");
|
||||
_Static_assert(sizeof(+e) == sizeof(int), "Result type should be int");
|
||||
_Static_assert(sizeof(+f.a) == sizeof(int), "Result type should be int");
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user