This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR c++/85400
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: Jason Merrill <jason at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 11 Jun 2018 15:30:22 +0200
- Subject: Re: [PATCH] Fix PR c++/85400
- References: <32444455.vUGMIimiic@polaris> <CADzB+2=QG==jTM_b7VnH1CuPJeUzJTSrogOJSQZdNVaGWfnr6g@mail.gmail.com> <2801364.hCAQSUSEjP@polaris> <1667256.3YmWegeGl2@polaris>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, May 09, 2018 at 12:05:34PM +0200, Eric Botcazou wrote:
> > So it isn't clear to me if a cxx_make_decl_one_only is the way to go. Maybe
> > doing the recalculation in comdat_linkage and maybe_make_one_only only
> > would be sufficient.
>
> Patch to that effect attached, tested on x86-64/Linux, OK for mainline?
>
>
> 2018-05-09 Eric Botcazou <ebotcazou@adacore.com>
>
> cp/
> PR c++/85400
> * decl2.c (adjust_var_decl_tls_model): New static function.
> (comdat_linkage): Call it on a variable.
> (maybe_make_one_only): Likewise.
>
> c-family/
> * c-attribs.c (handle_visibility_attribute): Do not set no_add_attrs.
Eric, do you plan to backport this to release branches?
> Index: cp/decl2.c
> ===================================================================
> --- cp/decl2.c (revision 259642)
> +++ cp/decl2.c (working copy)
> @@ -1838,6 +1838,17 @@ mark_vtable_entries (tree decl)
> }
> }
>
> +/* Adjust the TLS model on variable DECL if need be, typically after
> + the linkage of DECL has been modified. */
> +
> +static void
> +adjust_var_decl_tls_model (tree decl)
> +{
> + if (CP_DECL_THREAD_LOCAL_P (decl)
> + && !lookup_attribute ("tls_model", DECL_ATTRIBUTES (decl)))
> + set_decl_tls_model (decl, decl_default_tls_model (decl));
> +}
> +
> /* Set DECL up to have the closest approximation of "initialized common"
> linkage available. */
>
> @@ -1888,6 +1899,9 @@ comdat_linkage (tree decl)
>
> if (TREE_PUBLIC (decl))
> DECL_COMDAT (decl) = 1;
> +
> + if (VAR_P (decl))
> + adjust_var_decl_tls_model (decl);
> }
>
> /* For win32 we also want to put explicit instantiations in
> @@ -1926,6 +1940,8 @@ maybe_make_one_only (tree decl)
> /* Mark it needed so we don't forget to emit it. */
> node->forced_by_abi = true;
> TREE_USED (decl) = 1;
> +
> + adjust_var_decl_tls_model (decl);
> }
> }
> }
> Index: c-family/c-attribs.c
> ===================================================================
> --- c-family/c-attribs.c (revision 259642)
> +++ c-family/c-attribs.c (working copy)
> @@ -2299,14 +2299,13 @@ handle_visibility_attribute (tree *node,
>
> static tree
> handle_tls_model_attribute (tree *node, tree name, tree args,
> - int ARG_UNUSED (flags), bool *no_add_attrs)
> + int ARG_UNUSED (flags),
> + bool *ARG_UNUSED (no_add_attrs))
> {
> tree id;
> tree decl = *node;
> enum tls_model kind;
>
> - *no_add_attrs = true;
> -
> if (!VAR_P (decl) || !DECL_THREAD_LOCAL_P (decl))
> {
> warning (OPT_Wattributes, "%qE attribute ignored", name);
Jakub