From e83bc9d77564eeadcc415dbbc1352b3aaabb4fa7 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 6 Apr 2018 19:27:01 +0200 Subject: [PATCH] re PR c++/85210 (ICE with broken structured binding in template) 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 | 6 ++++++ gcc/cp/pt.c | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/cpp1z/decomp42.C | 18 ++++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1z/decomp42.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a27484b5e18..119741aa994 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2018-04-06 Jakub Jelinek + + 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 PR c++/85021 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3bac7563992..450ffaec9be 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e192061962e..30423e224b9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-04-06 Jakub Jelinek + + PR c++/85210 + * g++.dg/cpp1z/decomp42.C: New test. + 2018-04-06 David Malcolm 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 index 00000000000..c01db7f5d25 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp42.C @@ -0,0 +1,18 @@ +// PR c++/85210 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +struct A { int i; }; + +template +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); +} -- 2.30.2