Implement C++17 constexpr if.
authorJason Merrill <jason@redhat.com>
Wed, 10 Aug 2016 21:58:23 +0000 (17:58 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 10 Aug 2016 21:58:23 +0000 (17:58 -0400)
commit99f9d4b1b6bd7f072a84a0b19f0397bfa50008cb
tree387fdc4230f85dcbe03d25081a8bef0f7568d826
parente9e6d4f6cc2c0a3407c527f4c786b46508cb3366
Implement C++17 constexpr if.

* cp-tree.h (IF_STMT_CONSTEXPR_P): New.
* name-lookup.c (push_to_top_level, pop_from_top_level_1): Handle it.
* parser.h (struct cp_parser): Add in_discarded_stmt field.
* parser.c (cp_parser_selection_statement): Handle 'if constexpr'.
(cp_parser_jump_statement): Avoid deducing from a discarded return.
* pt.c (tsubst_expr): Only instantiate taken branch of constexpr if.
* semantics.c (begin_if_stmt): Set the binding level this_entity.
(finish_if_stmt_cond): Require the condition of a
constexpr if to be constant.
* decl.c (level_for_constexpr_if): New.
(named_label_entry): Add in_constexpr_if field.
(poplevel_named_label_1): Set it.
(check_goto): Check it.
(check_previous_goto_1): Check level_for_constexpr_if.

From-SVN: r239338
16 files changed:
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/parser.c
gcc/cp/parser.h
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/testsuite/g++.dg/cpp1z/constexpr-if1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/constexpr-if2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/constexpr-if3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/constexpr-if4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/constexpr-if5.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/constexpr-if6.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/constexpr-if7.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/constexpr-if8.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/constexpr-if9.C [new file with mode: 0644]