]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/85210 (ICE with broken structured binding in template)
authorJakub Jelinek <jakub@redhat.com>
Fri, 22 Jun 2018 21:07:16 +0000 (23:07 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 22 Jun 2018 21:07:16 +0000 (23:07 +0200)
Backported from mainline
2018-04-06  Jakub Jelinek  <jakub@redhat.com>

PR c++/85210
* pt.c (tsubst_decomp_names): Return error_mark_node and assert
errorcount is set if tsubst doesn't return a VAR_DECL.

* g++.dg/cpp1z/decomp42.C: New test.

From-SVN: r261949

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

index 6b08634faa20c932ed3784119050168bb12d463f..6700d1edeb5344dfef3d91c80a372ba2681f329a 100644 (file)
@@ -1,6 +1,12 @@
 2018-06-22  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-04-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/85210
+       * pt.c (tsubst_decomp_names): Return error_mark_node and assert
+       errorcount is set if tsubst doesn't return a VAR_DECL.
+
        2018-04-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/85208
index 5e79bc90af5dc41f89b195bf5bb648a309ab9f79..79cfd01292260a91b3e9fb2f72d03158ebe1013f 100644 (file)
@@ -15804,6 +15804,12 @@ tsubst_decomp_names (tree decl, tree pattern_decl, tree args,
       DECL_HAS_VALUE_EXPR_P (decl2) = 1;
       if (VAR_P (decl3))
        DECL_TEMPLATE_INSTANTIATED (decl3) = 1;
+      else
+       {
+         gcc_assert (errorcount);
+         decl = error_mark_node;
+         continue;
+       }
       maybe_push_decl (decl3);
       if (error_operand_p (decl3))
        decl = error_mark_node;
index 669b4bed1b72f31518fe0e1731965507a792c4eb..0fd38c54cbe9a151ea3f8b8866749963073dbd8e 100644 (file)
@@ -1,6 +1,11 @@
 2018-06-22  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-04-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/85210
+       * g++.dg/cpp1z/decomp42.C: New test.
+
        2018-04-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/85208
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp42.C b/gcc/testsuite/g++.dg/cpp1z/decomp42.C
new file mode 100644 (file)
index 0000000..22c68eb
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/85210
+// { dg-do compile { target c++11 } }
+// { dg-options "" }
+
+struct A { int i; };
+
+template <int>
+void
+foo (int j)
+{
+  auto [j] = A{j};     // { dg-error "shadows a parameter" }
+}                      // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .-1 }
+
+void
+bar ()
+{
+  foo<0> (0);
+}