PR c++/70344 - ICE with recursive constexpr
authorJason Merrill <jason@redhat.com>
Tue, 24 May 2016 03:34:55 +0000 (23:34 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Tue, 24 May 2016 03:34:55 +0000 (23:34 -0400)
* constexpr.c (cxx_eval_call_expression): Check for
fun == current_function_decl again.

From-SVN: r236625

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/g++.dg/cpp0x/constexpr-recursion2.C

index a93439cc7dc3dd3263876f92dee4a4b982196e4e..9095576dd4af6f893b15b1b08fad8ae102116ca5 100644 (file)
@@ -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.
index 7b562605b7b2c766869d3cbb97c2daddf3a9df5f..bb723f45b09ea4a45ae1658d3d332519e8d9ca37 100644 (file)
@@ -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))
index 978b998afebc258d8f5a298df4b2d194db9795c8..ce2280c856fe34fd46744c7b249cf356e5ac61d8 100644 (file)
@@ -1,5 +1,6 @@
 // PR c++/70344
 // { dg-do compile { target c++11 } }
+// { dg-options -O }
 
 struct Z
 {