mirror of
https://github.com/cc65/cc65.git
synced 2025-01-10 19:29:45 +00:00
Add a testcase for https://github.com/cc65/cc65/pull/757
This commit is contained in:
parent
a4b6bb63c0
commit
403783b649
@ -72,6 +72,11 @@ $(WORKDIR)/limits.$1.$2.prg: limits.c $(DIFF)
|
|||||||
$(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.out
|
$(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.out
|
||||||
$(DIFF) $(WORKDIR)/limits.$1.out limits.ref
|
$(DIFF) $(WORKDIR)/limits.$1.out limits.ref
|
||||||
|
|
||||||
|
$(WORKDIR)/goto.$1.$2.prg: goto.c $(DIFF)
|
||||||
|
$(if $(QUIET),echo misc/goto.$1.$2.prg)
|
||||||
|
$(CL65) -t sim$2 -$1 -o $$@ $$< 2>$(WORKDIR)/goto.$1.out
|
||||||
|
$(DIFF) $(WORKDIR)/goto.$1.out goto.ref
|
||||||
|
|
||||||
# the rest are tests that fail currently for one reason or another
|
# the rest are tests that fail currently for one reason or another
|
||||||
$(WORKDIR)/fields.$1.$2.prg: fields.c | $(WORKDIR)
|
$(WORKDIR)/fields.$1.$2.prg: fields.c | $(WORKDIR)
|
||||||
@echo "FIXME: " $$@ "currently will fail."
|
@echo "FIXME: " $$@ "currently will fail."
|
||||||
|
65
test/misc/goto.c
Normal file
65
test/misc/goto.c
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#define false 0
|
||||||
|
#define true (!false)
|
||||||
|
|
||||||
|
int main () {
|
||||||
|
int var = 3;
|
||||||
|
int quit = false;
|
||||||
|
|
||||||
|
goto finish;
|
||||||
|
|
||||||
|
while (!quit) {
|
||||||
|
var += 1;
|
||||||
|
{
|
||||||
|
if (var % 2) {
|
||||||
|
int var2 = 2;
|
||||||
|
int var3 = 4;
|
||||||
|
goto safe;
|
||||||
|
goto unsafe;
|
||||||
|
{
|
||||||
|
another:
|
||||||
|
var2 = 0x5599;
|
||||||
|
safe:
|
||||||
|
printf ("var2: %d\n", var2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
int var3 = 3;
|
||||||
|
int x = 4;
|
||||||
|
goto unsafe;
|
||||||
|
goto bad;
|
||||||
|
unused:
|
||||||
|
printf ("var3: %d\n", var3);
|
||||||
|
{
|
||||||
|
int var = 1;
|
||||||
|
bad:
|
||||||
|
var++;
|
||||||
|
if (var < 4)
|
||||||
|
goto bad;
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
unsafe:
|
||||||
|
var3 = 4;
|
||||||
|
goto another;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
int var = 2;
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var += 1;
|
||||||
|
if (var >= 10)
|
||||||
|
goto finish;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finish:
|
||||||
|
return var;
|
||||||
|
}
|
||||||
|
|
||||||
|
int function () {
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
end:
|
||||||
|
;
|
||||||
|
}
|
7
test/misc/goto.ref
Normal file
7
test/misc/goto.ref
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
goto.c(34): Warning: Goto from line 29 to label 'bad' can result in a trashed stack
|
||||||
|
goto.c(40): Warning: Goto from line 18 to label 'unsafe' can result in a trashed stack
|
||||||
|
goto.c(42): Warning: Goto from line 42 to label 'another' can result in a trashed stack
|
||||||
|
goto.c(47): Warning: Goto from line 47 to label 'bad' can result in a trashed stack
|
||||||
|
goto.c(56): Warning: Goto from line 38 to label 'finish' can result in a trashed stack
|
||||||
|
goto.c(58): Warning: `unused' is defined but never used
|
||||||
|
goto.c(65): Warning: Control reaches end of non-void function
|
Loading…
x
Reference in New Issue
Block a user