C++: accept loops with arbitrary labels or cases

This commit is contained in:
Robert Marsh
2018-10-22 09:59:49 -07:00
parent b40219bb01
commit 7bcc4379fc
2 changed files with 34 additions and 2 deletions

View File

@@ -50,3 +50,34 @@ int test5(int x, int y) {
return x;
}
void test6(int x, int cond) {
if (cond) {
x++;
} else goto end; // GOOD
x++;
end:
}
void test7(int x, int cond) {
if (cond)
{
goto target;
}
goto somewhere_else; // GOOD
while (x < 10) // not dead code
{
target:
x++;
}
somewhere_else:
switch (1)
{
goto end;
while (x < 10) // not dead code
{
case 1:
x++;
} break;
}
end:
}