re PR c++/71570 (ICE on invalid variable capture in cxx_incomplete_type_diagnostic...
authorPaolo Carlini <paolo.carlini@oracle.com>
Wed, 26 Jul 2017 21:46:22 +0000 (21:46 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Wed, 26 Jul 2017 21:46:22 +0000 (21:46 +0000)
/cp
2017-07-26  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/71570
* lambda.c (add_capture): Early return if we cannot capture by
reference.

/testsuite
2017-07-26  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/71570
* g++.dg/cpp0x/lambda/lambda-ice17.C: New.

From-SVN: r250591

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

index 9e763ae6d627778df85f5f0204ced591d1227a5c..bf3d249c0ec1bff8f2c5e2dee1a91c9633988943 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/71570
+       * lambda.c (add_capture): Early return if we cannot capture by
+       reference.
+
 2017-07-26  Jason Merrill  <jason@redhat.com>
 
        P0702R1 - List deduction of vector.
index 0e02375fa1b3f8382450534425965d685582ce3b..14ff6c2ae43c0e941fd106da46408a281c203108 100644 (file)
@@ -529,7 +529,10 @@ add_capture (tree lambda, tree id, tree orig_init, bool by_reference_p,
       else if (id != this_identifier && by_reference_p)
        {
          if (!lvalue_p (initializer))
-           error ("cannot capture %qE by reference", initializer);
+           {
+             error ("cannot capture %qE by reference", initializer);
+             return error_mark_node;
+           }
        }
       else
        {
index 61d174388a53fc14023ec59417cf1f8ae742ad05..39af41e5aa27be6abea4bf594dc332edd871e273 100644 (file)
@@ -1,3 +1,8 @@
+2017-07-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/71570
+       * g++.dg/cpp0x/lambda/lambda-ice17.C: New.
+
 2017-07-26  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/81563
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ice17.C
new file mode 100644 (file)
index 0000000..57111fd
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/71570
+// { dg-do compile { target c++11 } }
+
+void foo (int);
+
+void foo (void)
+{
+  [&foo] // { dg-error "cannot capture" }
+  {
+    foo (0);
+  };
+}