public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* c++: Fix unhiding friend with imports [PR 99248]
@ 2021-03-11 21:12 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2021-03-11 21:12 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 588 bytes --]


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.

-- 
Nathan Sidwell

[-- Attachment #2: pr99248.diff --]
[-- Type: text/x-patch, Size: 1967 bytes --]

diff --git c/gcc/cp/name-lookup.c w/gcc/cp/name-lookup.c
index 28271ba0485..d8839e29fe5 100644
--- c/gcc/cp/name-lookup.c
+++ w/gcc/cp/name-lookup.c
@@ -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;
 			}
 		    }
diff --git c/gcc/cp/ptree.c w/gcc/cp/ptree.c
index e06fe6f72c1..95a4fdf284a 100644
--- c/gcc/cp/ptree.c
+++ w/gcc/cp/ptree.c
@@ -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);
diff --git c/gcc/testsuite/g++.dg/modules/pr99248.h w/gcc/testsuite/g++.dg/modules/pr99248.h
new file mode 100644
index 00000000000..89d8dd5b39e
--- /dev/null
+++ w/gcc/testsuite/g++.dg/modules/pr99248.h
@@ -0,0 +1,5 @@
+class locale
+{
+  template<typename _Cache>
+  friend struct __use_cache;
+};
diff --git c/gcc/testsuite/g++.dg/modules/pr99248_a.H w/gcc/testsuite/g++.dg/modules/pr99248_a.H
new file mode 100644
index 00000000000..7f3fddad3bc
--- /dev/null
+++ w/gcc/testsuite/g++.dg/modules/pr99248_a.H
@@ -0,0 +1,5 @@
+// PR 99248 ICE with friend
+// { dg-additional-options -fmodule-header }
+// { dg-module-cmi {} }
+#include "pr99248.h"
+
diff --git c/gcc/testsuite/g++.dg/modules/pr99248_b.H w/gcc/testsuite/g++.dg/modules/pr99248_b.H
new file mode 100644
index 00000000000..33e242d4014
--- /dev/null
+++ w/gcc/testsuite/g++.dg/modules/pr99248_b.H
@@ -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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-11 21:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 21:12 c++: Fix unhiding friend with imports [PR 99248] Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).