From: Jason Merrill Date: Mon, 19 Jun 2017 20:55:27 +0000 (-0400) Subject: PR c++/80562 - ICE with constexpr if. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=66d052d5cb17463441615988fd2bbbeb292dfd04;p=gcc.git PR c++/80562 - ICE with constexpr if. * semantics.c (finish_if_stmt_cond): Call instantiate_non_dependent_expr. From-SVN: r249387 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ff4280aebd1..10d1ebd4859 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2017-06-19 Jason Merrill + 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. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 5b5ec5483d1..5fe772a49e3 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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 (); diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-if12.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-if12.C new file mode 100644 index 00000000000..1ed2c30c5c4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-if12.C @@ -0,0 +1,14 @@ +// PR c++/80562 +// { dg-options -std=c++1z } + +struct T { + constexpr auto foo() { return false; } +}; + +template +constexpr auto bf(T t) { + if constexpr(t.foo()) { + return false; + } + return true; +}