re PR c++/85209 (ICE with lambda and structured binding)
authorJakub Jelinek <jakub@redhat.com>
Thu, 5 Apr 2018 21:30:47 +0000 (23:30 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 5 Apr 2018 21:30:47 +0000 (23:30 +0200)
PR c++/85209
* pt.c (tsubst_decomp_names): Don't fail or ICE if DECL_CHAIN (decl3)
is not prev, if prev == decl.

* g++.dg/cpp1z/decomp39.C: New test.
* g++.dg/cpp1z/decomp40.C: New test.

From-SVN: r259156

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp1z/decomp39.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp1z/decomp40.C [new file with mode: 0644]

index 59c11be6fc4768de46b39fce2d5b513f6adb4541..759e9c99e0d7966dc3d1dd3ef8d686db1716a406 100644 (file)
@@ -1,5 +1,9 @@
 2018-04-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/85209
+       * pt.c (tsubst_decomp_names): Don't fail or ICE if DECL_CHAIN (decl3)
+       is not prev, if prev == decl.
+
        PR c++/85208
        * decl.c (start_decl): For DECL_DECOMPOSITION_P decls, don't call
        maybe_apply_pragma_weak here...
index dc2310aefa8540e9ff44addf499be52b95ca25bb..3bac7563992778af213c685b8d0eec447590a9c4 100644 (file)
@@ -16239,7 +16239,8 @@ tsubst_decomp_names (tree decl, tree pattern_decl, tree args,
       if (error_operand_p (decl3))
        decl = error_mark_node;
       else if (decl != error_mark_node
-              && DECL_CHAIN (decl3) != prev)
+              && DECL_CHAIN (decl3) != prev
+              && decl != prev)
        {
          gcc_assert (errorcount);
          decl = error_mark_node;
index 0a32f879906607afc625924fe19ecbc1262c08c9..a0008734d1b86483c56727a77e200bbeaf55bb7f 100644 (file)
@@ -1,5 +1,9 @@
 2018-04-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/85209
+       * g++.dg/cpp1z/decomp39.C: New test.
+       * g++.dg/cpp1z/decomp40.C: New test.
+
        PR c++/85208
        * g++.dg/cpp1z/decomp41.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp39.C b/gcc/testsuite/g++.dg/cpp1z/decomp39.C
new file mode 100644 (file)
index 0000000..fcc806a
--- /dev/null
@@ -0,0 +1,16 @@
+// PR c++/85209
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+template <int>
+void
+foo ()
+{
+  auto [a] = []{};     // { dg-error "cannot decompose lambda closure type" }
+}                      // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
+
+void
+bar ()
+{
+  foo<0> ();
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp40.C b/gcc/testsuite/g++.dg/cpp1z/decomp40.C
new file mode 100644 (file)
index 0000000..4210d6a
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/85209
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+struct S { int a; } s;
+
+template <int>
+void
+foo ()
+{
+  auto [a] = []{ return s; } ();       // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+};
+
+void
+bar ()
+{
+  foo<0> ();
+}