/* Instantiations of temploid friends imported from another module
need to be attached to the same module as the temploid. This maps
- these decls to the temploid they are instantiated them, as there is
+ these decls to the temploid they are instantiated from, as there is
no other easy way to get this information. */
static GTY((cache)) decl_tree_cache_map *imported_temploid_friends;
}
merge_kind mk = get_merge_kind (decl, dep);
- bool is_imported_temploid_friend = imported_temploid_friends->get (decl);
if (CHECKING_P)
{
is_attached = true;
bits.b (is_attached);
-
- /* Also tell the importer whether this is an imported temploid
- friend, which has implications for merging. */
- bits.b (is_imported_temploid_friend);
}
bits.b (dep && dep->has_defn ());
}
tree container = decl_container (decl);
unsigned tpl_levels = 0;
+ /* Also tell the importer whether this is a temploid friend attached
+ to a different module (which has implications for merging), so that
+ importers can reconstruct this information on stream-in. */
+ if (TREE_CODE (inner) == FUNCTION_DECL || TREE_CODE (inner) == TYPE_DECL)
+ {
+ tree* temploid_friend_slot = imported_temploid_friends->get (decl);
+ gcc_checking_assert (!temploid_friend_slot || *temploid_friend_slot);
+ tree_node (temploid_friend_slot ? *temploid_friend_slot : NULL_TREE);
+ }
+
{
auto wmk = make_temp_override (dep_hash->writing_merge_key, true);
if (decl != inner)
}
}
- if (is_imported_temploid_friend)
- {
- /* Write imported temploid friends so that importers can reconstruct
- this information on stream-in. */
- tree* slot = imported_temploid_friends->get (decl);
- tree_node (*slot);
- }
-
bool is_typedef = false;
if (!type && TREE_CODE (inner) == TYPE_DECL)
{
{
int tag = 0;
bool is_attached = false;
- bool is_imported_temploid_friend = false;
bool has_defn = false;
unsigned mk_u = u ();
if (mk_u >= MK_hwm || !merge_kind_name[mk_u])
{
bits_in bits = stream_bits ();
if (!(mk & MK_template_mask) && !state->is_header ())
- {
- is_attached = bits.b ();
- is_imported_temploid_friend = bits.b ();
- }
+ is_attached = bits.b ();
has_defn = bits.b ();
}
tree container = decl_container ();
unsigned tpl_levels = 0;
+ /* If this is an imported temploid friend, get the owning decl its
+ attachment is determined by (or NULL_TREE otherwise). */
+ tree temploid_friend = NULL_TREE;
+ if (TREE_CODE (inner) == FUNCTION_DECL || TREE_CODE (inner) == TYPE_DECL)
+ temploid_friend = tree_node ();
+
/* Figure out if this decl is already known about. */
int parm_tag = 0;
parm_tag = fn_parms_init (inner);
tree existing = key_mergeable (tag, mk, decl, inner, type, container,
- is_attached, is_imported_temploid_friend);
+ is_attached, temploid_friend);
tree existing_inner = existing;
if (existing)
{
}
}
- if (is_imported_temploid_friend)
- if (tree owner = tree_node ())
- if (is_new)
- imported_temploid_friends->put (decl, owner);
-
/* Regular typedefs will have a NULL TREE_TYPE at this point. */
unsigned tdef_flags = 0;
bool is_typedef = false;
DECL_MODULE_IMPORT_P (inner) = true;
}
+ if (temploid_friend)
+ imported_temploid_friends->put (decl, temploid_friend);
+
if (spec.spec)
set_constraints (decl, spec.spec);