From: Jakub Jelinek Date: Thu, 5 Apr 2018 21:29:51 +0000 (+0200) Subject: re PR c++/85208 (ICE with #pragma weak and structured binding) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a1afa75e015d3b139fc8fa0f1786ae4a9ccbf022;p=gcc.git re PR c++/85208 (ICE with #pragma weak and structured binding) PR c++/85208 * decl.c (start_decl): For DECL_DECOMPOSITION_P decls, don't call maybe_apply_pragma_weak here... (cp_maybe_mangle_decomp): ... but call it here instead. * g++.dg/cpp1z/decomp41.C: New test. From-SVN: r259155 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2c5e1e25f40..59c11be6fc4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2018-04-05 Jakub Jelinek + + PR c++/85208 + * decl.c (start_decl): For DECL_DECOMPOSITION_P decls, don't call + maybe_apply_pragma_weak here... + (cp_maybe_mangle_decomp): ... but call it here instead. + 2018-04-05 Jason Merrill PR c++/85136 - ICE with designated init in template. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 86251f51eb4..d55c2b70c0e 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5090,7 +5090,7 @@ start_decl (const cp_declarator *declarator, } /* If #pragma weak was used, mark the decl weak now. */ - if (!processing_template_decl) + if (!processing_template_decl && !DECL_DECOMPOSITION_P (decl)) maybe_apply_pragma_weak (decl); if (TREE_CODE (decl) == FUNCTION_DECL @@ -7510,6 +7510,7 @@ cp_maybe_mangle_decomp (tree decl, tree first, unsigned int count) for (unsigned int i = 0; i < count; i++, d = DECL_CHAIN (d)) v[count - i - 1] = d; SET_DECL_ASSEMBLER_NAME (decl, mangle_decomp (decl, v)); + maybe_apply_pragma_weak (decl); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d6a9738a177..0a32f879906 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-04-05 Jakub Jelinek + PR c++/85208 + * g++.dg/cpp1z/decomp41.C: New test. + PR middle-end/85195 * gcc.dg/pr85195.c: New test. diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp41.C b/gcc/testsuite/g++.dg/cpp1z/decomp41.C new file mode 100644 index 00000000000..3c8e1504c63 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/decomp41.C @@ -0,0 +1,9 @@ +// PR c++/85208 +// { dg-do compile { target c++11 } } +// { dg-require-weak "" } +// { dg-options "" } + +#pragma weak _ZDC1d1e1fE +struct A { int i, j, k; }; +auto [a, b, c] = A (); // { dg-warning "structured bindings only available with" "" { target c++14_down } } +auto [d, e, f] = A (); // { dg-warning "structured bindings only available with" "" { target c++14_down } }