From: Jakub Jelinek Date: Thu, 5 Apr 2018 21:30:47 +0000 (+0200) Subject: re PR c++/85209 (ICE with lambda and structured binding) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=86c9f54bb6e513b97fc40eeefd419a3f28ba451e;p=gcc.git re PR c++/85209 (ICE with lambda and structured binding) PR c++/85209 * pt.c (tsubst_decomp_names): Don't fail or ICE if DECL_CHAIN (decl3) is not prev, if prev == decl. * g++.dg/cpp1z/decomp39.C: New test. * g++.dg/cpp1z/decomp40.C: New test. From-SVN: r259156 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 59c11be6fc4..759e9c99e0d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2018-04-05 Jakub Jelinek + PR c++/85209 + * pt.c (tsubst_decomp_names): Don't fail or ICE if DECL_CHAIN (decl3) + is not prev, if prev == decl. + PR c++/85208 * decl.c (start_decl): For DECL_DECOMPOSITION_P decls, don't call maybe_apply_pragma_weak here... diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index dc2310aefa8..3bac7563992 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -16239,7 +16239,8 @@ tsubst_decomp_names (tree decl, tree pattern_decl, tree args, if (error_operand_p (decl3)) decl = error_mark_node; else if (decl != error_mark_node - && DECL_CHAIN (decl3) != prev) + && DECL_CHAIN (decl3) != prev + && decl != prev) { gcc_assert (errorcount); decl = error_mark_node; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0a32f879906..a0008734d1b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2018-04-05 Jakub Jelinek + PR c++/85209 + * g++.dg/cpp1z/decomp39.C: New test. + * g++.dg/cpp1z/decomp40.C: New test. + PR c++/85208 * g++.dg/cpp1z/decomp41.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp39.C b/gcc/testsuite/g++.dg/cpp1z/decomp39.C new file mode 100644 index 00000000000..fcc806a472b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp39.C @@ -0,0 +1,16 @@ +// PR c++/85209 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +template +void +foo () +{ + auto [a] = []{}; // { dg-error "cannot decompose lambda closure type" } +} // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 } + +void +bar () +{ + foo<0> (); +} diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp40.C b/gcc/testsuite/g++.dg/cpp1z/decomp40.C new file mode 100644 index 00000000000..4210d6af6c7 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp40.C @@ -0,0 +1,18 @@ +// PR c++/85209 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +struct S { int a; } s; + +template +void +foo () +{ + auto [a] = []{ return s; } (); // { dg-warning "structured bindings only available with" "" { target c++14_down } } +}; + +void +bar () +{ + foo<0> (); +}