c++: Fix unhiding friend with imports [PR 99248]

This was a simple thinko about which object held the reference to the
binding vector.  I also noticed stale code in the tree dumper, as I
recently removed the flags from a lazy number.

	PR c++/99248
	gcc/cp/
	* name-lookup.c (lookup_elaborated_type_1): Access slot not bind
	when there's a binding vector.
	* ptree.c (cxx_print_xnode): Lazy flags are no longer a thing.
	gcc/testsuite/
	* g++.dg/modules/pr99248.h: New.
	* g++.dg/modules/pr99248_a.H: New.
	* g++.dg/modules/pr99248_b.H: New.
This commit is contained in:
Nathan Sidwell 2021-03-11 13:06:36 -08:00
parent 5643f6f396
commit 5f27a9f90d
5 changed files with 19 additions and 3 deletions

View File

@ -7940,7 +7940,7 @@ lookup_elaborated_type_1 (tree name, TAG_how how)
if (*slot == bind)
*slot = decl;
else
BINDING_VECTOR_CLUSTER (bind, 0)
BINDING_VECTOR_CLUSTER (*slot, 0)
.slots[BINDING_SLOT_CURRENT] = decl;
}
}

View File

@ -310,8 +310,7 @@ cxx_print_xnode (FILE *file, tree node, int indent)
{
indent_to (file, indent + 4);
unsigned lazy = slot.get_lazy ();
fprintf (file, "%s snum:%u flags:%d",
pfx, lazy >> 2, lazy & 3);
fprintf (file, "%s snum:%u", pfx, lazy);
}
else if (slot)
print_node (file, pfx, slot, indent + 4);

View File

@ -0,0 +1,5 @@
class locale
{
template<typename _Cache>
friend struct __use_cache;
};

View File

@ -0,0 +1,5 @@
// PR 99248 ICE with friend
// { dg-additional-options -fmodule-header }
// { dg-module-cmi {} }
#include "pr99248.h"

View File

@ -0,0 +1,7 @@
// { dg-additional-options -fmodule-header }
// { dg-module-cmi {} }
#include "pr99248.h"
import "pr99248_a.H";
template<typename _Facet>
struct __use_cache;