Added several flow control tests.
This commit is contained in:
@@ -152,7 +152,37 @@ $(WORKDIR)/bug2655.$1.$2.prg: bug2655.c $(ISEQUAL) | $(WORKDIR)
|
||||
$(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLOUT) 2>$(WORKDIR)/bug2655.$1.$2.out
|
||||
$(ISEQUAL) $(WORKDIR)/bug2655.$1.$2.out bug2655.ref
|
||||
|
||||
$(WORKDIR)/limits.$1.$2.prg: limits.c $(ISEQUAL) | $(WORKDIR)
|
||||
$(WORKDIR)/flow-do-01.$1.$2.prg: flow-do-01.c $(ISEQUAL) | $(WORKDIR)
|
||||
$(if $(QUIET),echo misc/flow-do-01.$1.$2.prg)
|
||||
$(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLOUT) 2>$(WORKDIR)/flow-do-01.$1.$2.out
|
||||
$(ISEQUAL) $(WORKDIR)/flow-do-01.$1.$2.out flow-do-01.ref
|
||||
|
||||
$(WORKDIR)/flow-if-01.$1.$2.prg: flow-if-01.c $(ISEQUAL) | $(WORKDIR)
|
||||
$(if $(QUIET),echo misc/flow-if-01.$1.$2.prg)
|
||||
$(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLOUT) 2>$(WORKDIR)/flow-if-01.$1.$2.out
|
||||
$(ISEQUAL) $(WORKDIR)/flow-if-01.$1.$2.out flow-if-01.ref
|
||||
|
||||
$(WORKDIR)/flow-if-02.$1.$2.prg: flow-if-02.c $(ISEQUAL) | $(WORKDIR)
|
||||
$(if $(QUIET),echo misc/flow-if-02.$1.$2.prg)
|
||||
$(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLOUT) 2>$(WORKDIR)/flow-if-02.$1.$2.out
|
||||
$(ISEQUAL) $(WORKDIR)/flow-if-02.$1.$2.out flow-if-02.ref
|
||||
|
||||
$(WORKDIR)/flow-switch-01.$1.$2.prg: flow-switch-01.c $(ISEQUAL) | $(WORKDIR)
|
||||
$(if $(QUIET),echo misc/flow-switch-01.$1.$2.prg)
|
||||
$(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLOUT) 2>$(WORKDIR)/flow-switch-01.$1.$2.out
|
||||
$(ISEQUAL) $(WORKDIR)/flow-switch-01.$1.$2.out flow-switch-01.ref
|
||||
|
||||
$(WORKDIR)/flow-while-01.$1.$2.prg: flow-while-01.c $(ISEQUAL) | $(WORKDIR)
|
||||
$(if $(QUIET),echo misc/flow-while-01.$1.$2.prg)
|
||||
$(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLOUT) 2>$(WORKDIR)/flow-while-01.$1.$2.out
|
||||
$(ISEQUAL) $(WORKDIR)/flow-while-01.$1.$2.out flow-while-01.ref
|
||||
|
||||
$(WORKDIR)/flow-while-02.$1.$2.prg: flow-while-02.c $(ISEQUAL) | $(WORKDIR)
|
||||
$(if $(QUIET),echo misc/flow-while-02.$1.$2.prg)
|
||||
$(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLOUT) 2>$(WORKDIR)/flow-while-02.$1.$2.out
|
||||
$(ISEQUAL) $(WORKDIR)/flow-while-02.$1.$2.out flow-while-02.ref
|
||||
|
||||
$(WORKDIR)/limits.$1.$2.prg: limits.c $(ISEQUAL) | $(WORKDIR)
|
||||
$(if $(QUIET),echo misc/limits.$1.$2.prg)
|
||||
$(CC65) -t sim$2 -$1 -o $$(@:.prg=.s) $$< $(NULLOUT) $(CATERR)
|
||||
$(CA65) -t sim$2 -o $$(@:.prg=.o) $$(@:.prg=.s) $(NULLERR)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
bug2655.c:5: Warning: Unreachable code
|
||||
bug2655.c:12: Warning: Unreachable code
|
||||
bug2655.c:6: Warning: Unreachable code
|
||||
bug2655.c:13: Warning: Unreachable code
|
||||
|
||||
87
test/misc/flow-do-01.c
Normal file
87
test/misc/flow-do-01.c
Normal file
@@ -0,0 +1,87 @@
|
||||
int a;
|
||||
|
||||
static int f1(void)
|
||||
{
|
||||
do {
|
||||
return a;
|
||||
} while (a == 2);
|
||||
/* Unreachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f2(void)
|
||||
{
|
||||
do {
|
||||
return a;
|
||||
} while (1);
|
||||
/* Unreachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f3(void)
|
||||
{
|
||||
do {
|
||||
return a;
|
||||
} while (0);
|
||||
/* Unreachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f4(void)
|
||||
{
|
||||
do {
|
||||
continue; /* Turns do/while into an endless loop */
|
||||
} while (0);
|
||||
/* Unreachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f5(void)
|
||||
{
|
||||
do {
|
||||
if (a == 2) {
|
||||
break;
|
||||
}
|
||||
return a;
|
||||
} while (0);
|
||||
/* Reachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f6(void)
|
||||
{
|
||||
do {
|
||||
if (a == 2) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
} while (0);
|
||||
/* Reachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f7(void)
|
||||
{
|
||||
do {
|
||||
if (a == 2) {
|
||||
return a;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} while (1);
|
||||
/* Unreachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return f1() + f2() + f3() + f4() + f5() + f6() + f7();
|
||||
}
|
||||
|
||||
5
test/misc/flow-do-01.ref
Normal file
5
test/misc/flow-do-01.ref
Normal file
@@ -0,0 +1,5 @@
|
||||
flow-do-01.c:9: Warning: Unreachable code
|
||||
flow-do-01.c:19: Warning: Unreachable code
|
||||
flow-do-01.c:29: Warning: Unreachable code
|
||||
flow-do-01.c:39: Warning: Unreachable code
|
||||
flow-do-01.c:79: Warning: Unreachable code
|
||||
62
test/misc/flow-if-01.c
Normal file
62
test/misc/flow-if-01.c
Normal file
@@ -0,0 +1,62 @@
|
||||
int a, b;
|
||||
|
||||
static int f1(void)
|
||||
{
|
||||
if (a == 1) {
|
||||
return 1;
|
||||
}
|
||||
/* Reachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f2(void)
|
||||
{
|
||||
if (a == 1) {
|
||||
a = 2;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
/* Reachable */
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f3(void)
|
||||
{
|
||||
if (a == 1) {
|
||||
return 1;
|
||||
} else {
|
||||
a = 2;
|
||||
}
|
||||
/* Reachable */
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f4(void)
|
||||
{
|
||||
if (a == 1) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
/* Unreachable */
|
||||
a = 2;
|
||||
}
|
||||
|
||||
static int f5(void)
|
||||
{
|
||||
if (1) {
|
||||
return 1;
|
||||
} else {
|
||||
/* Unreachable */
|
||||
return 0;
|
||||
}
|
||||
/* Unreachable */
|
||||
a = 2;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return f1() + f2() + f3() + f4() + f5();
|
||||
}
|
||||
|
||||
3
test/misc/flow-if-01.ref
Normal file
3
test/misc/flow-if-01.ref
Normal file
@@ -0,0 +1,3 @@
|
||||
flow-if-01.c:43: Warning: Unreachable code
|
||||
flow-if-01.c:52: Warning: Unreachable code
|
||||
flow-if-01.c:55: Warning: Unreachable code
|
||||
49
test/misc/flow-if-02.c
Normal file
49
test/misc/flow-if-02.c
Normal file
@@ -0,0 +1,49 @@
|
||||
int a, b;
|
||||
|
||||
static int f1(void)
|
||||
{
|
||||
if (0) {
|
||||
/* Unreachable but no warning */
|
||||
} else {
|
||||
a = 2;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f2(void)
|
||||
{
|
||||
if (0) {
|
||||
/* Unreachable */
|
||||
a = 1;
|
||||
} else {
|
||||
a = 2;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f3(void)
|
||||
{
|
||||
if (1) {
|
||||
a = 2;
|
||||
} else {
|
||||
/* Unreachable but no warning */
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f4(void)
|
||||
{
|
||||
if (1) {
|
||||
a = 2;
|
||||
} else {
|
||||
/* Unreachable */
|
||||
a = 1;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return f1() + f2() + f3() + f4();
|
||||
}
|
||||
|
||||
2
test/misc/flow-if-02.ref
Normal file
2
test/misc/flow-if-02.ref
Normal file
@@ -0,0 +1,2 @@
|
||||
flow-if-02.c:17: Warning: Unreachable code
|
||||
flow-if-02.c:40: Warning: Unreachable code
|
||||
68
test/misc/flow-switch-01.c
Normal file
68
test/misc/flow-switch-01.c
Normal file
@@ -0,0 +1,68 @@
|
||||
int a;
|
||||
|
||||
static int f1(void)
|
||||
{
|
||||
switch (a) {
|
||||
/* Unreachable */
|
||||
a = 3;
|
||||
case 1:
|
||||
a = 2;
|
||||
break;
|
||||
case 2:
|
||||
a = 1;
|
||||
break;
|
||||
default:
|
||||
a = 0;
|
||||
break;
|
||||
}
|
||||
/* Reachable */
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f2(void)
|
||||
{
|
||||
switch (a) {
|
||||
/* Reachable */
|
||||
L: a = 3;
|
||||
case 1:
|
||||
goto L;
|
||||
case 2:
|
||||
a = 1;
|
||||
break;
|
||||
default:
|
||||
a = 0;
|
||||
break;
|
||||
}
|
||||
/* Reachable */
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f3(void)
|
||||
{
|
||||
switch (a) {
|
||||
case 1: return a;
|
||||
case 2: return a+1;
|
||||
default: return a+2;
|
||||
}
|
||||
/* Unreachable but no warning */
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f4(void)
|
||||
{
|
||||
switch (a) {
|
||||
/* No warning */
|
||||
do {
|
||||
case 1: ++a; continue;
|
||||
case 2: return a+1;
|
||||
default: return a+2;
|
||||
} while (1);
|
||||
}
|
||||
/* Unreachable but no warning */
|
||||
return a;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return f1() + f2() + f3() + f4();
|
||||
}
|
||||
1
test/misc/flow-switch-01.ref
Normal file
1
test/misc/flow-switch-01.ref
Normal file
@@ -0,0 +1 @@
|
||||
flow-switch-01.c:7: Warning: Unreachable code
|
||||
70
test/misc/flow-while-01.c
Normal file
70
test/misc/flow-while-01.c
Normal file
@@ -0,0 +1,70 @@
|
||||
int a;
|
||||
|
||||
static int f1(void)
|
||||
{
|
||||
while (1) {
|
||||
++a;
|
||||
}
|
||||
/* Unreachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f2(void)
|
||||
{
|
||||
while (1) {
|
||||
++a;
|
||||
if (a == 5) break;
|
||||
}
|
||||
/* Reachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f3(void)
|
||||
{
|
||||
while (1) {
|
||||
++a;
|
||||
return a;
|
||||
}
|
||||
/* Unreachable */
|
||||
a = 2;
|
||||
}
|
||||
|
||||
static int f4(void)
|
||||
{
|
||||
while (0) {
|
||||
/* Unreachable */
|
||||
++a;
|
||||
return a;
|
||||
}
|
||||
/* Reachable */
|
||||
a = 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int f5(void)
|
||||
{
|
||||
while (1) {
|
||||
++a;
|
||||
if (a == 4) goto L;
|
||||
return a;
|
||||
}
|
||||
/* Reachable via L */
|
||||
L: a = 2;
|
||||
}
|
||||
|
||||
static int f6(void)
|
||||
{
|
||||
while (0) {
|
||||
/* Unreachable but no warning */
|
||||
}
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return f1() + f2() + f3() + f4() + f5() + f6();
|
||||
}
|
||||
|
||||
3
test/misc/flow-while-01.ref
Normal file
3
test/misc/flow-while-01.ref
Normal file
@@ -0,0 +1,3 @@
|
||||
flow-while-01.c:9: Warning: Unreachable code
|
||||
flow-while-01.c:31: Warning: Unreachable code
|
||||
flow-while-01.c:38: Warning: Unreachable code
|
||||
74
test/misc/flow-while-02.c
Normal file
74
test/misc/flow-while-02.c
Normal file
@@ -0,0 +1,74 @@
|
||||
int a;
|
||||
|
||||
static int f1(void)
|
||||
{
|
||||
while (1) {
|
||||
while (0) {
|
||||
/* Unreachable */
|
||||
++a;
|
||||
}
|
||||
}
|
||||
/* Unreachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f2(void)
|
||||
{
|
||||
while (1) {
|
||||
do {
|
||||
return a;
|
||||
} while (0);
|
||||
/* Unreachable */
|
||||
break;
|
||||
}
|
||||
/* Unreachable but no warning */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f3(void)
|
||||
{
|
||||
do {
|
||||
while (1) {
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
/* Unreachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f4(void)
|
||||
{
|
||||
do {
|
||||
while (1) {
|
||||
return a;
|
||||
}
|
||||
} while (0);
|
||||
/* Unreachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
static int f5(void)
|
||||
{
|
||||
do {
|
||||
do {
|
||||
if (a == 2) {
|
||||
return a;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} while (0);
|
||||
} while (0);
|
||||
/* Unreachable */
|
||||
a = 2;
|
||||
return a;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
return f1()/ + f2() + f3() + f4() + f5();
|
||||
}
|
||||
|
||||
6
test/misc/flow-while-02.ref
Normal file
6
test/misc/flow-while-02.ref
Normal file
@@ -0,0 +1,6 @@
|
||||
flow-while-02.c:8: Warning: Unreachable code
|
||||
flow-while-02.c:12: Warning: Unreachable code
|
||||
flow-while-02.c:23: Warning: Unreachable code
|
||||
flow-while-02.c:38: Warning: Unreachable code
|
||||
flow-while-02.c:50: Warning: Unreachable code
|
||||
flow-while-02.c:66: Warning: Unreachable code
|
||||
Reference in New Issue
Block a user