re PR c++/85210 (ICE with broken structured binding in template)
authorJakub Jelinek <jakub@redhat.com>
Fri, 6 Apr 2018 17:27:01 +0000 (19:27 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 6 Apr 2018 17:27:01 +0000 (19:27 +0200)
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: r259181

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

index a27484b5e18a71cb4dcc897b924f0ae8a50614a8..119741aa9941ec8d6f1b81776c8af127337f601b 100644 (file)
@@ -1,3 +1,9 @@
+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-06  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/85021
index 3bac7563992778af213c685b8d0eec447590a9c4..450ffaec9bec2cd2453532b49cd950b33528a85b 100644 (file)
@@ -16235,6 +16235,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 e192061962e87a8b1e30581264a39acb873e248f..30423e224b9623b382285508fe977f288fec5520 100644 (file)
@@ -1,3 +1,8 @@
+2018-04-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/85210
+       * g++.dg/cpp1z/decomp42.C: New test.
+
 2018-04-06  David Malcolm  <dmalcolm@redhat.com>
 
        PR c++/85021
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..c01db7f
--- /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 "structured bindings only available with" "" { target c++14_down } .-1 }
+
+void
+bar ()
+{
+  foo<0> (0);
+}