module.cc (friend_from_decl_list): Reimplement.

gcc/cp/
	* module.cc (friend_from_decl_list): Reimplement.
	(trees_out::tree_decl): When streaming a local template friend
	reference, make sure we find one.

From-SVN: r275179
This commit is contained in:
Nathan Sidwell
2019-08-30 14:11:38 +00:00
committed by Nathan Sidwell
parent 5c5bc07d61
commit 71ced5cec1
2 changed files with 35 additions and 21 deletions

View File

@@ -1,5 +1,10 @@
2019-08-30 Nathan Sidwell <nathan@acm.org>
gcc/cp/
* module.cc (friend_from_decl_list): Reimplement.
(trees_out::tree_decl): When streaming a local template friend
reference, make sure we find one.
gcc/cp/
* module.cc (enum tree_tag): Drop tt_mergeable, tt_clone.
(trees_out::tree_value): Emit tt_node & kind separately.

View File

@@ -4406,25 +4406,30 @@ maybe_strip_cmi_prefix (char *to)
return to;
}
/* Given a CLASSTYPE_DECL_LIST VALUE get the friend decl, if that's
what this is. */
/* Given a CLASSTYPE_DECL_LIST VALUE get the the template friend decl,
if that's what this is. */
static tree
friend_from_decl_list (tree frnd)
{
if (TYPE_P (frnd))
if (TREE_CODE (frnd) != TEMPLATE_DECL)
{
if (!CLASSTYPE_TEMPLATE_INFO (frnd))
frnd = NULL_TREE; // reachable?
tree maybe_template = frnd;
if (TYPE_P (frnd))
{
if (CLASSTYPE_TEMPLATE_INFO (frnd))
maybe_template = CLASSTYPE_TI_TEMPLATE (frnd);
}
else
frnd = CLASSTYPE_TI_TEMPLATE (frnd);
{
if (DECL_TEMPLATE_INFO (frnd))
maybe_template = DECL_TI_TEMPLATE (frnd);
}
if (TREE_CODE (maybe_template) == TEMPLATE_DECL)
frnd = maybe_template;
}
else if (TREE_CODE (frnd) == TEMPLATE_DECL)
;
else if (!DECL_TEMPLATE_INFO (frnd))
frnd = NULL; // FIXME: Is this ever reachable?
else if (TREE_CODE (DECL_TI_TEMPLATE (frnd)) == TEMPLATE_DECL)
frnd = DECL_TI_TEMPLATE (frnd);
return frnd;
}
@@ -7166,22 +7171,26 @@ trees_out::tree_decl (tree decl, walk_kind ref, bool looking_inside)
if (streaming_p ())
{
unsigned ix = 0;
for (tree decls = CLASSTYPE_DECL_LIST (klass);;
decls = TREE_CHAIN (decls))
tree decls = CLASSTYPE_DECL_LIST (klass);
for (unsigned ix = 0;; decls = TREE_CHAIN (decls))
if (!TREE_PURPOSE (decls))
{
if (tree frnd = friend_from_decl_list (TREE_VALUE (decls)))
if (frnd == decl)
tree frnd = friend_from_decl_list (TREE_VALUE (decls));
if (frnd == decl)
{
u (ix);
dump (dumper::TREE)
&& dump ("Wrote friend %N[%u], %C:%N",
klass, ix, TREE_CODE (decl), decl);
break;
}
/* Count every friend to make streaming in simpler. */
ix++;
}
u (ix);
dump (dumper::TREE)
&& dump ("Wrote friend %N[%u], %C:%N",
klass, ix, TREE_CODE (decl), decl);
/* We must have found it. */
gcc_checking_assert (decls);
}
return false;