Hi! During parsing we report error here, the decomp id shadowing parameter, but we still have a VAR_DECL for the decomp id, only during tsubst_decomp_names tsubst returns a PARM_DECL for it.
I believe and (the code asserts that) this can only happen during error recovery and we just should punt on it, we don't want to pushdecl it, nor try to create lds_decomp DECL_LANG_SPECIFIC for it (PARM_DECLs have lds_parm, so that is where we ICE on this testcase), etc. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2018-04-06 Jakub Jelinek <ja...@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. --- gcc/cp/pt.c.jj 2018-04-05 23:30:11.315435539 +0200 +++ gcc/cp/pt.c 2018-04-06 11:46:34.170154030 +0200 @@ -16235,6 +16235,12 @@ tsubst_decomp_names (tree decl, tree pat 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; --- gcc/testsuite/g++.dg/cpp1z/decomp42.C.jj 2018-04-06 11:45:39.724162398 +0200 +++ gcc/testsuite/g++.dg/cpp1z/decomp42.C 2018-04-06 11:45:39.724162398 +0200 @@ -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); +} Jakub