]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/cp/constexpr.c
PR c++/77467
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 28 Sep 2016 19:21:47 +0000 (19:21 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 28 Sep 2016 19:21:47 +0000 (19:21 +0000)
commit2a2770c6502b2b227c525c8f5c491f66dd69dd21
tree87190ab17a07d003e50e369e06ccb1875e978e4f
parent4785ab7437d2a666dd09bf98d5eec2a32cca7109
PR c++/77467
* constexpr.c (enum constexpr_switch_state): New.
(struct constexpr_ctx): Add css_state field.
(label_matches): Add CTX and STMT arguments, remove I and
DEFAULT_LABEL.  For CASE_LABEL_EXPR assert ctx->css_state != NULL,
handle default labels according to css_state.
(cxx_eval_statement_list): Remove statement skipping, label_matches
and default_label handling code.
(cxx_eval_loop_expr): Exit after first iteration even if
switches (jump_target).
(cxx_eval_switch_expr): Set up css_state field in ctx, if default
label has been seen in the body, but no cases matched, evaluate
the body second time.
(cxx_eval_constant_expression): Handle stmt skipping and label_matches
here.  Handle PREDICT_EXPR.  For MODIFY_EXPR or INIT_EXPR, assert
statement is not skipped.  For COND_EXPR during skipping, don't
evaluate condition, just the then block and if still skipping at the
end also the else block.
(cxx_eval_outermost_constant_expr): Adjust constexpr_ctx initializer.
(is_sub_constant_expr): Likewise.

* g++.dg/cpp1y/constexpr-77467.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240591 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1y/constexpr-77467.C [new file with mode: 0644]