Fix fallthrough of non-entered stmt expressions
commit ec5d94291 made is to that the nocode_wanted state from
inside a statement expression is retained after it. That is wrong
if the statement expression can't be entered to start with. In the
latter case the state from before the stmt-expr is the one we need.
This commit is contained in:
parent
ebb4e71236
commit
73c22f831f
3 changed files with 17 additions and 3 deletions
9
tccgen.c
9
tccgen.c
|
|
@ -5394,9 +5394,12 @@ ST_FUNC void unary(void)
|
||||||
outside, so any reactivation of code emission (from labels
|
outside, so any reactivation of code emission (from labels
|
||||||
or loop heads) can be disabled again after the end of it. */
|
or loop heads) can be disabled again after the end of it. */
|
||||||
block(1);
|
block(1);
|
||||||
/* or'ing to keep however possible CODE_OFF() from e.g. "return 0;"
|
/* If the statement expr can be entered, then we retain the current
|
||||||
in the statement expression */
|
nocode_wanted state (from e.g. a 'return 0;' in the stmt-expr).
|
||||||
nocode_wanted |= saved_nocode_wanted;
|
If it can't be entered then the state is that from before the
|
||||||
|
statement expression. */
|
||||||
|
if (saved_nocode_wanted)
|
||||||
|
nocode_wanted = saved_nocode_wanted;
|
||||||
skip(')');
|
skip(')');
|
||||||
} else {
|
} else {
|
||||||
gexpr();
|
gexpr();
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,15 @@ static void dowhile(void)
|
||||||
} while (check());
|
} while (check());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void nondead_after_dead_return(void)
|
||||||
|
{
|
||||||
|
/* This statement expr is not entered, and hence that fact that it
|
||||||
|
doesn't fall-through should not influence the surrounding code. */
|
||||||
|
0 && ({ return; 0;});
|
||||||
|
printf ("nondead works\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
@ -150,6 +159,7 @@ enterloop3:
|
||||||
}
|
}
|
||||||
|
|
||||||
dowhile();
|
dowhile();
|
||||||
|
nondead_after_dead_return();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,3 +21,4 @@ check 1
|
||||||
g=2
|
g=2
|
||||||
check 2
|
check 2
|
||||||
g=3
|
g=3
|
||||||
|
nondead works
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue