return HT_IDENT_TO_GCC_IDENT (HT_NODE (const_cast<cpp_hashnode *> (node)));
}
-/* During duplicate detection we need to tell some comparators that
- these are equivalent. */
-tree map_context_from;
-tree map_context_to;
-
/* Id for dumping module information. */
int module_dump_id;
if (spec.spec)
set_constraints (decl, spec.spec);
- if (mk & MK_template_mask
- || mk == MK_partial)
- {
- /* Add to specialization tables now that constraints etc are
- added. */
- bool is_type = mk == MK_partial || !(mk & MK_tmpl_decl_mask);
-
- spec.spec = is_type ? type : mk & MK_tmpl_tmpl_mask ? inner : decl;
- add_mergeable_specialization (!is_type, &spec, decl, spec_flags);
- }
if (TREE_CODE (decl) == INTEGER_CST && !TREE_OVERFLOW (decl))
{
/* Set the TEMPLATE_DECL's type. */
TREE_TYPE (decl) = TREE_TYPE (inner);
+ if (mk & MK_template_mask
+ || mk == MK_partial)
+ {
+ /* Add to specialization tables now that constraints etc are
+ added. */
+ bool is_type = mk == MK_partial || !(mk & MK_tmpl_decl_mask);
+
+ spec.spec = is_type ? type : mk & MK_tmpl_tmpl_mask ? inner : decl;
+ add_mergeable_specialization (!is_type,
+ !is_type && mk & MK_tmpl_alias_mask,
+ &spec, decl, spec_flags);
+ }
+
if (NAMESPACE_SCOPE_P (decl)
&& (mk == MK_named || mk == MK_unique
|| mk == MK_enum || mk == MK_friend_spec)
&& !(VAR_OR_FUNCTION_DECL_P (decl) && DECL_LOCAL_DECL_P (decl)))
add_module_namespace_decl (CP_DECL_CONTEXT (decl), decl);
- /* The late insertion of an alias here or an implicit member
- (next block), is ok, because we ensured that all imports were
- loaded up before we started this cluster. Thus an insertion
- from some other import cannot have happened between the
- merged insertion above and these insertions down here. */
- if (mk == MK_alias_spec)
- {
- /* Insert into type table. */
- tree ti = DECL_TEMPLATE_INFO (inner);
- spec_entry elt =
- {TI_TEMPLATE (ti), TI_ARGS (ti), TREE_TYPE (inner)};
- tree texist = match_mergeable_specialization (false, &elt);
- if (texist)
- set_overrun ();
- }
-
if (DECL_ARTIFICIAL (decl)
&& TREE_CODE (decl) == FUNCTION_DECL
&& !DECL_TEMPLATE_INFO (decl)
if (!is_matching_decl (existing, decl, is_typedef))
unmatched_duplicate (existing);
+ if (inner && TREE_CODE (inner) == FUNCTION_DECL)
+ {
+ tree e_inner = STRIP_TEMPLATE (existing);
+ for (auto parm = DECL_ARGUMENTS (inner);
+ parm; parm = DECL_CHAIN (parm))
+ DECL_CONTEXT (parm) = e_inner;
+ }
+
/* And our result is the existing node. */
decl = existing;
}
if (!e)
{
spec.spec = inner;
- add_mergeable_specialization (true, &spec, decl, spec_flags);
+ add_mergeable_specialization (true, false, &spec, decl, spec_flags);
}
else if (e != existing)
set_overrun ();
{
if (mk & MK_tmpl_alias_mask)
/* It should be in both tables. */
- gcc_assert (match_mergeable_specialization (false, entry)
- == TREE_TYPE (existing));
+ gcc_checking_assert
+ (match_mergeable_specialization (false, entry)
+ == TREE_TYPE (existing));
else if (mk & MK_tmpl_tmpl_mask)
existing = DECL_TI_TEMPLATE (existing);
}
}
/* The walkabout should have found ourselves. */
- gcc_assert (existing == decl);
+ gcc_checking_assert (existing == decl);
}
}
else if (mk != MK_unique)
break;
case FUNCTION_DECL:
- map_context_from = d_inner;
- map_context_to = m_inner;
if (tree m_type = TREE_TYPE (m_inner))
if ((!key.ret
|| same_type_p (key.ret, fndecl_declared_return_type (m_inner)))
if (cp_tree_equal (key.constraints, m_reqs))
found = match;
}
- map_context_from = map_context_to = NULL_TREE;
break;
case TYPE_DECL:
gcc_checking_assert (TREE_CODE (e_inner) == TREE_CODE (d_inner));
}
- gcc_checking_assert (!map_context_from);
- /* This mapping requres the new decl on the lhs and the existing
- entity on the rhs of the comparitors below. */
- map_context_from = d_inner;
- map_context_to = e_inner;
-
if (TREE_CODE (d_inner) == FUNCTION_DECL)
{
tree e_ret = fndecl_declared_return_type (existing);
else if (!cp_tree_equal (TREE_TYPE (decl), TREE_TYPE (existing)))
{
mismatch:
- map_context_from = map_context_to = NULL_TREE;
if (DECL_IS_UNDECLARED_BUILTIN (existing))
/* Just like duplicate_decls, presum the user knows what
they're doing in overriding a builtin. */
}
}
- map_context_from = map_context_to = NULL_TREE;
-
if (DECL_IS_UNDECLARED_BUILTIN (existing)
&& !DECL_IS_UNDECLARED_BUILTIN (decl))
{
tree maybe_dup = odr_duplicate (maybe_template, DECL_SAVED_TREE (decl));
bool installing = maybe_dup && !DECL_SAVED_TREE (decl);
- if (maybe_dup)
- for (auto parm = DECL_ARGUMENTS (maybe_dup); parm; parm = DECL_CHAIN (parm))
- DECL_CONTEXT (parm) = decl;
-
if (int wtag = i ())
{
int tag = 1;
|| DECL_CLASS_TEMPLATE_P (entry->tmpl));
/* Only alias templates can appear in both tables (and
- if they're in the type table they must also be in the decl table). */
+ if they're in the type table they must also be in the decl
+ table). */
gcc_checking_assert
(!match_mergeable_specialization (true, entry)
- == (decl_p || !DECL_ALIAS_TEMPLATE_P (entry->tmpl)));
+ == !DECL_ALIAS_TEMPLATE_P (entry->tmpl));
}
else if (VAR_OR_FUNCTION_DECL_P (entry->spec))
gcc_checking_assert (!DECL_LOCAL_DECL_P (entry->spec));
get_mergeable_specialization_flags. */
void
-add_mergeable_specialization (bool decl_p, spec_entry *elt,
+add_mergeable_specialization (bool decl_p, bool alias_p, spec_entry *elt,
tree decl, unsigned flags)
{
- hash_table<spec_hasher> *specializations
- = decl_p ? decl_specializations : type_specializations;
-
hashval_t hash = spec_hasher::hash (elt);
- auto *slot = specializations->find_slot_with_hash (elt, hash, INSERT);
-
- /* We don't distinguish different constrained partial type
- specializations, so there could be duplicates. Everything else
- must be new. */
- if (!(flags & 2 && *slot))
+ if (decl_p)
{
- gcc_checking_assert (!*slot);
+ auto *slot = decl_specializations->find_slot_with_hash (elt, hash, INSERT);
+ gcc_checking_assert (!*slot);
auto entry = ggc_alloc<spec_entry> ();
*entry = *elt;
*slot = entry;
+
+ if (alias_p)
+ {
+ elt->spec = TREE_TYPE (elt->spec);
+ gcc_checking_assert (elt->spec);
+ }
+ }
+
+ if (!decl_p || alias_p)
+ {
+ auto *slot = type_specializations->find_slot_with_hash (elt, hash, INSERT);
+
+ /* We don't distinguish different constrained partial type
+ specializations, so there could be duplicates. Everything else
+ must be new. */
+ if (!(flags & 2 && *slot))
+ {
+ gcc_checking_assert (!*slot);
+
+ auto entry = ggc_alloc<spec_entry> ();
+ *entry = *elt;
+ *slot = entry;
+ }
}
if (flags & 1)