On 3/26/19 6:28 PM, Jakub Jelinek wrote:
Hi!
As the testcase shows, the SWITCH_STMT handling in
potential_constant_expression_1
is quite conservative, it doesn't recurse on the body of the switch stmt,
because at least for the case where the switch condition isn't some easily
determinable constant, we'd need to try all possible values of the switch
expression (or start walking from all possible case labels, see PR for
details), but right now potential_constant_expression_1 doesn't have the
careful stmt skipping logic cxx_eval_* has anyway.
So, the following patch still doesn't recurse on SWITCH_STMT_BODY using
potential_constant_expression_1, but instead checks if the body contains
a return or continue stmt (the latter only if not nested in some loop body
inside of the switch body). If there is no return nor continue, assuming
there is no endless loop (which wouldn't be constant expression due to the
ops limit) the switch body must fall through to the code after it.
If there is a return or continue, we set *jump_target to it.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK.
Jason