PR c++/80562 - ICE with constexpr if.

* semantics.c (finish_if_stmt_cond): Call
	instantiate_non_dependent_expr.

From-SVN: r249387
This commit is contained in:
Jason Merrill 2017-06-19 16:55:27 -04:00 committed by Jason Merrill
parent ecc5761533
commit 66d052d5cb
3 changed files with 22 additions and 1 deletions

View File

@ -1,5 +1,9 @@
2017-06-19 Jason Merrill <jason@redhat.com>
PR c++/80562 - ICE with constexpr if.
* semantics.c (finish_if_stmt_cond): Call
instantiate_non_dependent_expr.
PR c++/80829 - ICE with constexpr copy of base subobject.
* constexpr.c (clear_no_implicit_zero): New.
(cxx_eval_call_expression): Call it.

View File

@ -733,7 +733,10 @@ finish_if_stmt_cond (tree cond, tree if_stmt)
if (IF_STMT_CONSTEXPR_P (if_stmt)
&& require_potential_rvalue_constant_expression (cond)
&& !value_dependent_expression_p (cond))
cond = cxx_constant_value (cond, NULL_TREE);
{
cond = instantiate_non_dependent_expr (cond);
cond = cxx_constant_value (cond, NULL_TREE);
}
finish_cond (&IF_COND (if_stmt), cond);
add_stmt (if_stmt);
THEN_CLAUSE (if_stmt) = push_stmt_list ();

View File

@ -0,0 +1,14 @@
// PR c++/80562
// { dg-options -std=c++1z }
struct T {
constexpr auto foo() { return false; }
};
template <class MustBeTemplate>
constexpr auto bf(T t) {
if constexpr(t.foo()) {
return false;
}
return true;
}