/* Merge the threadprivate attribute. */
if (TREE_CODE (olddecl) == VAR_DECL && C_DECL_THREADPRIVATE_P (olddecl))
- {
- set_decl_tls_model (newdecl, DECL_TLS_MODEL (olddecl));
- C_DECL_THREADPRIVATE_P (newdecl) = 1;
- }
+ C_DECL_THREADPRIVATE_P (newdecl) = 1;
if (CODE_CONTAINS_STRUCT (TREE_CODE (olddecl), TS_DECL_WITH_VIS))
{
- /* Merge the section attribute.
- We want to issue an error if the sections conflict but that
- must be done later in decl_attributes since we are called
- before attributes are assigned. */
- if ((DECL_EXTERNAL (olddecl) || TREE_PUBLIC (olddecl) || TREE_STATIC (olddecl))
- && DECL_SECTION_NAME (newdecl) == NULL
- && DECL_SECTION_NAME (olddecl))
- set_decl_section_name (newdecl, DECL_SECTION_NAME (olddecl));
-
/* Copy the assembler name.
Currently, it can only be defined in the prototype. */
COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
(char *) newdecl + sizeof (struct tree_decl_common),
tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common));
olddecl->decl_with_vis.symtab_node = snode;
+
+ if ((DECL_EXTERNAL (olddecl)
+ || TREE_PUBLIC (olddecl)
+ || TREE_STATIC (olddecl))
+ && DECL_SECTION_NAME (newdecl) != NULL)
+ set_decl_section_name (olddecl, DECL_SECTION_NAME (newdecl));
+
+ /* This isn't quite correct for something like
+ int __thread x attribute ((tls_model ("local-exec")));
+ extern int __thread x;
+ as we'll lose the "local-exec" model. */
+ if (TREE_CODE (olddecl) == VAR_DECL
+ && DECL_THREAD_LOCAL_P (newdecl))
+ set_decl_tls_model (olddecl, DECL_TLS_MODEL (newdecl));
break;
}
if (!DECL_LANG_SPECIFIC (newdecl))
retrofit_lang_decl (newdecl);
- set_decl_tls_model (newdecl, DECL_TLS_MODEL (olddecl));
CP_DECL_THREADPRIVATE_P (newdecl) = 1;
}
}
}
}
- /* Merge the section attribute.
- We want to issue an error if the sections conflict but that must be
- done later in decl_attributes since we are called before attributes
- are assigned. */
- if ((DECL_EXTERNAL (olddecl) || TREE_PUBLIC (olddecl) || TREE_STATIC (olddecl))
- && DECL_SECTION_NAME (newdecl) == NULL
- && DECL_SECTION_NAME (olddecl) != NULL)
- set_decl_section_name (newdecl, DECL_SECTION_NAME (olddecl));
-
if (TREE_CODE (newdecl) == FUNCTION_DECL)
{
DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl)
/* Merge the storage class information. */
merge_weak (newdecl, olddecl);
- if ((TREE_CODE (olddecl) == FUNCTION_DECL || TREE_CODE (olddecl) == VAR_DECL)
- && (DECL_EXTERNAL (olddecl) || TREE_PUBLIC (olddecl) || TREE_STATIC (olddecl))
- && DECL_ONE_ONLY (olddecl))
- {
- struct symtab_node *symbol;
- if (TREE_CODE (olddecl) == FUNCTION_DECL)
- symbol = cgraph_node::get_create (newdecl);
- else
- symbol = varpool_node::get_create (newdecl);
- symbol->set_comdat_group (symtab_node::get
- (olddecl)->get_comdat_group ());
- }
-
DECL_DEFER_OUTPUT (newdecl) |= DECL_DEFER_OUTPUT (olddecl);
TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
TREE_STATIC (olddecl) = TREE_STATIC (newdecl) |= TREE_STATIC (olddecl);
}
else
{
- size_t size = tree_code_size (TREE_CODE (olddecl));
+ size_t size = tree_code_size (TREE_CODE (newdecl));
memcpy ((char *) olddecl + sizeof (struct tree_common),
(char *) newdecl + sizeof (struct tree_common),
sizeof (struct tree_decl_common) - sizeof (struct tree_common));
- switch (TREE_CODE (olddecl))
+ switch (TREE_CODE (newdecl))
{
case LABEL_DECL:
case VAR_DECL:
{
struct symtab_node *snode = NULL;
- if (TREE_CODE (olddecl) == VAR_DECL
+ if (TREE_CODE (newdecl) == VAR_DECL
&& (TREE_STATIC (olddecl) || TREE_PUBLIC (olddecl) || DECL_EXTERNAL (olddecl)))
snode = symtab_node::get (olddecl);
memcpy ((char *) olddecl + sizeof (struct tree_decl_common),
(char *) newdecl + sizeof (struct tree_decl_common),
size - sizeof (struct tree_decl_common)
+ TREE_CODE_LENGTH (TREE_CODE (newdecl)) * sizeof (char *));
- if (TREE_CODE (olddecl) == VAR_DECL)
+ if (TREE_CODE (newdecl) == VAR_DECL)
olddecl->decl_with_vis.symtab_node = snode;
}
break;
break;
}
}
+
+ if (TREE_CODE (newdecl) == FUNCTION_DECL
+ || TREE_CODE (newdecl) == VAR_DECL)
+ {
+ if (DECL_EXTERNAL (olddecl)
+ || TREE_PUBLIC (olddecl)
+ || TREE_STATIC (olddecl))
+ {
+ /* Merge the section attribute.
+ We want to issue an error if the sections conflict but that must be
+ done later in decl_attributes since we are called before attributes
+ are assigned. */
+ if (DECL_SECTION_NAME (newdecl) != NULL)
+ set_decl_section_name (olddecl, DECL_SECTION_NAME (newdecl));
+
+ if (DECL_ONE_ONLY (newdecl))
+ {
+ struct symtab_node *oldsym, *newsym;
+ if (TREE_CODE (olddecl) == FUNCTION_DECL)
+ oldsym = cgraph_node::get_create (olddecl);
+ else
+ oldsym = varpool_node::get_create (olddecl);
+ newsym = symtab_node::get (newdecl);
+ oldsym->set_comdat_group (newsym->get_comdat_group ());
+ }
+ }
+
+ if (TREE_CODE (newdecl) == VAR_DECL
+ && DECL_THREAD_LOCAL_P (newdecl))
+ set_decl_tls_model (olddecl, DECL_TLS_MODEL (newdecl));
+ }
+
DECL_UID (olddecl) = olddecl_uid;
if (olddecl_friend)
DECL_FRIEND_P (olddecl) = 1;