From: Jakub Jelinek Date: Fri, 22 Jun 2018 21:06:41 +0000 (+0200) Subject: backport: re PR c++/85208 (ICE with #pragma weak and structured binding) X-Git-Tag: releases/gcc-7.4.0~341 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75bcfc00e5346cef2e0e4738fa0fbfcef91017e6;p=thirdparty%2Fgcc.git backport: re PR c++/85208 (ICE with #pragma weak and structured binding) Backported from mainline 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. * g++.dg/cpp1z/decomp41.C: New test. From-SVN: r261948 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a3bec6f43140..6b08634faa20 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,6 +1,13 @@ 2018-06-22 Jakub Jelinek Backported from mainline + 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-04 Jakub Jelinek PR inline-asm/85172 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2193dd929f85..950e04a66807 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5022,7 +5022,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 @@ -7422,6 +7422,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 25011ca786d5..669b4bed1b72 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2018-06-22 Jakub Jelinek Backported from mainline + 2018-04-05 Jakub Jelinek + + PR c++/85208 + * g++.dg/cpp1z/decomp41.C: New test. + 2018-04-04 Jakub Jelinek PR inline-asm/85172 diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp41.C b/gcc/testsuite/g++.dg/cpp1z/decomp41.C new file mode 100644 index 000000000000..1ce836bd6dd7 --- /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 "decomposition declaration only available with" "" { target c++14_down } } +auto [d, e, f] = A (); // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }