Hi,

when back in 2014 I sent the patch for c++/61088 I noticed some cases where we wanted to return early error_mark_node from add_capture to avoid ICEs during error recovery when COMPLETE_TYPE_P is used on an error_mark_node. The new testcase noticed one additional case, where the error_mark_node is returned by lambda_capture_field_type. I propose to just immediately check it. Alternately we could add the check to the else branch of the following conditional (which also passes testing) or somewhere else too, I guess. Tested x86_64-linux.

Thanks,

Paolo.

////////////////////////

/cp
2016-08-04  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/72800
        * lambda.c (add_capture): Check lambda_capture_field_type return
        value for error_mark_node.

/testsuite
2016-08-04  Paolo Carlini  <paolo.carl...@oracle.com>

        PR c++/72800
        * g++.dg/cpp1y/lambda-ice1.C: New.
Index: cp/lambda.c
===================================================================
--- cp/lambda.c (revision 239118)
+++ cp/lambda.c (working copy)
@@ -492,6 +492,8 @@ add_capture (tree lambda, tree id, tree orig_init,
   else
     {
       type = lambda_capture_field_type (initializer, explicit_init_p);
+      if (type == error_mark_node)
+       return error_mark_node;
       if (by_reference_p)
        {
          type = build_reference_type (type);
Index: testsuite/g++.dg/cpp1y/lambda-ice1.C
===================================================================
--- testsuite/g++.dg/cpp1y/lambda-ice1.C        (revision 0)
+++ testsuite/g++.dg/cpp1y/lambda-ice1.C        (working copy)
@@ -0,0 +1,7 @@
+// PR c++/72800
+// { dg-do compile { target c++14 } }
+
+void foo ()
+{
+  [n {}] {};  // { dg-error "one element|deducing" }
+}

Reply via email to