From: Jakub Jelinek Date: Wed, 29 Aug 2018 12:27:55 +0000 (+0200) Subject: re PR c++/87122 (ICE in tsubst_decomp_names) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f5b219ccc233001ee610d5a57ccb22ec4cb24f53;p=gcc.git re PR c++/87122 (ICE in tsubst_decomp_names) PR c++/87122 * pt.c (tsubst_expr) : If processing_template_decl and decl is structured binding decl, call cp_finish_decomp. * g++.dg/cpp1z/decomp47.C: New test. From-SVN: r263953 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7c5946a3151..82d6659d615 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -39,7 +39,7 @@ * genpreds.c (write_predicate_subfunction): Also add ATTRIBUTE_UNUSED to OP parmeter of generated function. -2018-08-28 MCC CS +2018-08-28 MCC CS PR tree-optimization/87009 * match.pd: Add boolean optimizations. diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 087beb679fb..57479570bd4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-08-29 Jakub Jelinek + + PR c++/87122 + * pt.c (tsubst_expr) : If + processing_template_decl and decl is structured binding decl, call + cp_finish_decomp. + 2018-08-28 Paolo Carlini PR c++/86546 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a7266e368fc..0a618a5447d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -16832,6 +16832,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, RANGE_FOR_IVDEP (stmt) = RANGE_FOR_IVDEP (t); RANGE_FOR_UNROLL (stmt) = RANGE_FOR_UNROLL (t); finish_range_for_decl (stmt, decl, expr); + if (decomp_first && decl != error_mark_node) + cp_finish_decomp (decl, decomp_first, decomp_cnt); } else { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bd9d31aec7b..17ea5c7421d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-08-29 Jakub Jelinek + + PR c++/87122 + * g++.dg/cpp1z/decomp47.C: New test. + 2018-08-29 Matthew Malcomson * gcc.target/aarch64/simd/vect_su_add_sub.c: Use 32 and 64-bit types @@ -13,7 +18,7 @@ PR tree-optimization/87126 * gcc.dg/tree-ssa/pr87126.c: New testcase. -2018-08-28 MCC CS +2018-08-28 MCC CS PR tree-optimization/87009 * gcc.dg/pr87009.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp47.C b/gcc/testsuite/g++.dg/cpp1z/decomp47.C new file mode 100644 index 00000000000..f0d202d696a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp47.C @@ -0,0 +1,32 @@ +// PR c++/87122 +// { dg-do run { target c++14 } } +// { dg-options "" } + +extern "C" void abort (); +struct S { int a, b; }; +int c; + +template +void +foo () +{ + S x[4] = { { N, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; + auto f = [](auto & y) { + for (auto & [ u, v ] : y) // { dg-warning "structured bindings only available with" "" { target c++14_down } } + { + if ((u & 1) != 1 || v != u + 1 || u < N || u > 7 || (c & (1 << u)) + || &u != &y[v / 2 - 1].a || &v != &y[v / 2 - 1].b) + abort (); + c |= 1 << u; + } + }; + f (x); +} + +int +main () +{ + foo<1> (); + if (c != 0xaa) + abort (); +}