re PR c++/59791 (ICE: Error reporting routines re-entered. with -fcompare-debug)
authorJason Merrill <jason@redhat.com>
Wed, 29 Jan 2014 04:10:58 +0000 (23:10 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 29 Jan 2014 04:10:58 +0000 (23:10 -0500)
PR c++/59791
* pt.c (tsubst_decl) [VAR_DECL]: Allow in unevaluated context.
(tsubst_copy): Use it if lookup fails.

From-SVN: r207224

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype1.C [new file with mode: 0644]

index 502f218..31217e7 100644 (file)
@@ -1,5 +1,9 @@
 2014-01-28  Jason Merrill  <jason@redhat.com>
 
+       PR c++/59791
+       * pt.c (tsubst_decl) [VAR_DECL]: Allow in unevaluated context.
+       (tsubst_copy): Use it if lookup fails.
+
        PR c++/59818
        * pt.c (tsubst_function_type): Make sure we keep the same function
        quals.
index 011db2c..7f1b6d5 100644 (file)
@@ -10990,9 +10990,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain)
            DECL_TEMPLATE_INFO (r) = build_template_info (tmpl, argvec);
            SET_DECL_IMPLICIT_INSTANTIATION (r);
          }
-       else if (cp_unevaluated_operand)
-         gcc_unreachable ();
-       else
+       else if (!cp_unevaluated_operand)
          register_local_specialization (r, t);
 
        DECL_CHAIN (r) = NULL_TREE;
@@ -12481,6 +12479,11 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
                }
              else
                {
+                 /* This can happen for a variable used in a late-specified
+                    return type of a local lambda.  Just make a dummy decl
+                    since it's only used for its type.  */
+                 if (cp_unevaluated_operand)
+                   return tsubst_decl (t, args, complain);
                  gcc_assert (errorcount || sorrycount);
                  return error_mark_node;
                }
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype1.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-decltype1.C
new file mode 100644 (file)
index 0000000..0ab0cdd
--- /dev/null
@@ -0,0 +1,21 @@
+// PR c++/59791
+// We force the gimple dump to trigger use of lang_decl_name.
+// { dg-options "-std=c++11 -fdump-tree-gimple" }
+// { dg-final { cleanup-tree-dump "gimple" } }
+
+template < class T > void
+f (T t)
+{
+  int i = t;
+  [](int)->decltype (i + t)
+  {
+    return 0;
+  }
+  (0);
+}
+
+void
+foo ()
+{
+  f (0);
+}