From: laubzega Date: Wed, 26 Sep 2018 06:54:45 +0000 (-0700) Subject: Added testcase for between-blocks gotos. X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4b78d40e9788efccb747ae38362b6ce23f32d48f;p=cc65 Added testcase for between-blocks gotos. Deleted old testcase. --- diff --git a/test/misc/Makefile b/test/misc/Makefile index 83d6e03ba..330c9d500 100644 --- a/test/misc/Makefile +++ b/test/misc/Makefile @@ -72,12 +72,6 @@ $(WORKDIR)/limits.$1.$2.prg: limits.c $(DIFF) $(SIM65) $(SIM65FLAGS) $$@ > $(WORKDIR)/limits.$1.out $(DIFF) $(WORKDIR)/limits.$1.out limits.ref -# here we check if the right errors are produced -$(WORKDIR)/goto.$1.$2.prg: goto.c $(DIFF) - $(if $(QUIET),echo misc/goto.$1.$2.prg) - $(NOT) $(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 $(WORKDIR)/fields.$1.$2.prg: fields.c | $(WORKDIR) @echo "FIXME: " $$@ "currently will fail." diff --git a/test/misc/goto.c b/test/misc/goto.c deleted file mode 100644 index 6d16722e1..000000000 --- a/test/misc/goto.c +++ /dev/null @@ -1,65 +0,0 @@ -#include -#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: - return 0; -} diff --git a/test/misc/goto.ref b/test/misc/goto.ref deleted file mode 100644 index e319a153f..000000000 --- a/test/misc/goto.ref +++ /dev/null @@ -1,6 +0,0 @@ -goto.c(34): Error: Goto from line 29 to label 'bad' can result in a trashed stack -goto.c(40): Error: Goto from line 18 to label 'unsafe' can result in a trashed stack -goto.c(42): Error: Goto from line 42 to label 'another' can result in a trashed stack -goto.c(47): Error: Goto from line 47 to label 'bad' can result in a trashed stack -goto.c(56): Error: Goto from line 38 to label 'finish' can result in a trashed stack -goto.c(58): Warning: `unused' is defined but never used diff --git a/test/ref/goto.c b/test/ref/goto.c new file mode 100644 index 000000000..3a445e647 --- /dev/null +++ b/test/ref/goto.c @@ -0,0 +1,35 @@ +#include + +int main () { + char a[200] = "xyz"; + int ctr = 0; +start: + a[ctr] = ctr + 65; + goto second; + + { + char b[64] = "xxx"; + first: + b[0] = ctr + 97; + goto safe; + b[0] = 'Z'; + safe: + printf ("%c%c", a[0], b[0]); + if (ctr++ > 20) + goto end; + else + goto second; + } + { + char c[100] = "aaa"; + second:; + c[0] = '1'; + c[99] = '2'; + goto first; + } +end: + a[ctr] = '\n'; + printf ("\n%s\n", a); + + return 0; +}