aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2016-05-24 03:34:55 +0000
committerJason Merrill <jason@redhat.com>2016-05-24 03:34:55 +0000
commit482b5f262e1e416df61944ccdec6f030d44186dc (patch)
tree92858b6ab0cbaf8978593fb1a44fa74bc3284415
parentdb4fde0d768b3d23ddf2abed64bcac5d693beb97 (diff)
PR c++/70344 - ICE with recursive constexpr
* constexpr.c (cxx_eval_call_expression): Check for fun == current_function_decl again. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@236625 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/constexpr.c10
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/constexpr-recursion2.C1
3 files changed, 13 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a93439cc7dc..9095576dd4a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2016-05-23 Jason Merrill <jason@redhat.com>
+ PR c++/70344
+ * constexpr.c (cxx_eval_call_expression): Check for
+ fun == current_function_decl again.
+
PR c++/70584
* cp-gimplify.c (cp_fold) [INDIRECT_REF]: Call
maybe_undo_parenthesized_ref.
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 7b562605b7b..bb723f45b09 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -1371,11 +1371,17 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
else
{
new_call.fundef = retrieve_constexpr_fundef (fun);
- if (new_call.fundef == NULL || new_call.fundef->body == NULL)
+ if (new_call.fundef == NULL || new_call.fundef->body == NULL
+ || fun == current_function_decl)
{
if (!ctx->quiet)
{
- if (DECL_INITIAL (fun) == error_mark_node)
+ /* We need to check for current_function_decl here in case we're
+ being called during cp_fold_function, because at that point
+ DECL_INITIAL is set properly and we have a fundef but we
+ haven't lowered invisirefs yet (c++/70344). */
+ if (DECL_INITIAL (fun) == error_mark_node
+ || fun == current_function_decl)
error_at (loc, "%qD called in a constant expression before its "
"definition is complete", fun);
else if (DECL_INITIAL (fun))
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-recursion2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-recursion2.C
index 978b998afeb..ce2280c856f 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-recursion2.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-recursion2.C
@@ -1,5 +1,6 @@
// PR c++/70344
// { dg-do compile { target c++11 } }
+// { dg-options -O }
struct Z
{