OK.
On Thu, Apr 5, 2018 at 5:06 PM, Jakub Jelinek <ja...@redhat.com> wrote: > Hi! > > We can't call maybe_apply_pragma_weak for structured binding decls > at start_decl time, as that is too early, we don't have DECL_ASSEMBLER_NAME > computed yet for them and because we don't have the corresponding decls > around yet, we can't even compute it. > > This patch defers the maybe_apply_pragma_weak call from start_decl to > cp_maybe_mangle_decomp where we just added the mangling the call needs. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2018-04-05 Jakub Jelinek <ja...@redhat.com> > > 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/decomp42.C: New test. > > --- gcc/cp/decl.c.jj 2018-04-04 21:33:20.532639396 +0200 > +++ gcc/cp/decl.c 2018-04-05 13:29:39.128215719 +0200 > @@ -5090,7 +5090,7 @@ start_decl (const cp_declarator *declara > } > > /* 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 > @@ -7483,6 +7483,7 @@ cp_maybe_mangle_decomp (tree decl, tree > 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); > } > } > > --- gcc/testsuite/g++.dg/cpp1z/decomp42.C.jj 2018-04-05 13:45:39.521220008 > +0200 > +++ gcc/testsuite/g++.dg/cpp1z/decomp42.C 2018-04-05 13:45:22.507220268 > +0200 > @@ -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 } } > > Jakub