Code suppression fixes

See adjusted testcase, a lone break; in a do while loop was
incorrectly disabling the exit test.
This commit is contained in:
Michael Matz 2017-11-14 15:38:40 +01:00
parent 8294285d8f
commit 7ad2cf8d68
3 changed files with 40 additions and 0 deletions

View File

@ -6088,6 +6088,8 @@ static void block(int *bsym, int *csym, int is_expr)
skip(TOK_WHILE);
skip('(');
gsym(b);
if (b)
nocode_wanted = saved_nocode_wanted;
gexpr();
c = gvtst(0, 0);
gsym_addr(c, d);

View File

@ -26,6 +26,36 @@ static void kb_wait_1(void)
timeout--;
} while (timeout);
}
static int global;
static void foo(int i)
{
global+=i;
printf ("g=%d\n", global);
}
static int check(void)
{
printf ("check %d\n", global);
return 1;
}
static void dowhile(void)
{
do {
foo(1);
if (global == 1) {
continue;
} else if (global == 2) {
continue;
}
/* The following break shouldn't disable the check() call,
as it's reachable by the continues above. */
break;
} while (check());
}
int main (void)
{
int i = 1;
@ -118,5 +148,8 @@ enterloop3:
printf ("error4\n");
}
}
dowhile();
return 0;
}

View File

@ -16,3 +16,8 @@ once3
twice3
caseok
caseok2
g=1
check 1
g=2
check 2
g=3