Added another test.
This commit is contained in:
@@ -177,6 +177,11 @@ $(WORKDIR)/flow-switch-01.$1.$2.prg: flow-switch-01.c $(ISEQUAL) | $(WORKDIR)
|
|||||||
$(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLOUT) 2>$(WORKDIR)/flow-switch-01.$1.$2.out
|
$(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
|
$(ISEQUAL) $(WORKDIR)/flow-switch-01.$1.$2.out flow-switch-01.ref
|
||||||
|
|
||||||
|
$(WORKDIR)/flow-switch-02.$1.$2.prg: flow-switch-02.c $(ISEQUAL) | $(WORKDIR)
|
||||||
|
$(if $(QUIET),echo misc/flow-switch-02.$1.$2.prg)
|
||||||
|
$(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLOUT) 2>$(WORKDIR)/flow-switch-02.$1.$2.out
|
||||||
|
$(ISEQUAL) $(WORKDIR)/flow-switch-02.$1.$2.out flow-switch-02.ref
|
||||||
|
|
||||||
$(WORKDIR)/flow-while-01.$1.$2.prg: flow-while-01.c $(ISEQUAL) | $(WORKDIR)
|
$(WORKDIR)/flow-while-01.$1.$2.prg: flow-while-01.c $(ISEQUAL) | $(WORKDIR)
|
||||||
$(if $(QUIET),echo misc/flow-while-01.$1.$2.prg)
|
$(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
|
$(CC65) -t sim$2 -$1 -o $$@ $$< $(NULLOUT) 2>$(WORKDIR)/flow-while-01.$1.$2.out
|
||||||
|
|||||||
107
test/misc/flow-switch-02.c
Normal file
107
test/misc/flow-switch-02.c
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
char a, b;
|
||||||
|
|
||||||
|
static int f1(void)
|
||||||
|
{
|
||||||
|
switch (a) {
|
||||||
|
case 1: return 1;
|
||||||
|
case 0xFF: break;
|
||||||
|
default: return 2;
|
||||||
|
}
|
||||||
|
/* Reachable */
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f2(void)
|
||||||
|
{
|
||||||
|
switch (a) {
|
||||||
|
case 1: return 1;
|
||||||
|
case 0x100: break; /* Unreachable */
|
||||||
|
default: return 2;
|
||||||
|
}
|
||||||
|
/* Unreachable despite the "break" above */
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f3(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (a) {
|
||||||
|
case 1:
|
||||||
|
if (b > 128) {
|
||||||
|
a = 2;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
a = 1;
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
default:
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
/* Reachable */
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f4(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (a) {
|
||||||
|
case 1:
|
||||||
|
if (b > 255) {
|
||||||
|
/* Unreachable */
|
||||||
|
a = 2;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
a = 1;
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
default:
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
/* Unreachable despite the "break" above */
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f5(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (a) {
|
||||||
|
case 1:
|
||||||
|
if (b >= 0) {
|
||||||
|
a = 2;
|
||||||
|
} else {
|
||||||
|
/* Unreachable */
|
||||||
|
a = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
default:
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
/* Unreachable despite the "break" above */
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int f6(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch (a) {
|
||||||
|
case 1:
|
||||||
|
while (0) {
|
||||||
|
/* Unreachable */
|
||||||
|
if (b >= 128) {
|
||||||
|
a = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
default:
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
/* Unreachable despite the "break" above */
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
return f1() + f2() + f3() + f4() + f5() + f6();
|
||||||
|
}
|
||||||
10
test/misc/flow-switch-02.ref
Normal file
10
test/misc/flow-switch-02.ref
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
flow-switch-02.c:18: Warning: Case value (256) out of range for switch condition type
|
||||||
|
flow-switch-02.c:22: Warning: Unreachable code
|
||||||
|
flow-switch-02.c:49: Warning: Result of comparison is always false
|
||||||
|
flow-switch-02.c:51: Warning: Unreachable code
|
||||||
|
flow-switch-02.c:61: Warning: Unreachable code
|
||||||
|
flow-switch-02.c:69: Warning: Result of comparison is always true
|
||||||
|
flow-switch-02.c:73: Warning: Unreachable code
|
||||||
|
flow-switch-02.c:81: Warning: Unreachable code
|
||||||
|
flow-switch-02.c:91: Warning: Unreachable code
|
||||||
|
flow-switch-02.c:101: Warning: Unreachable code
|
||||||
Reference in New Issue
Block a user