aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathaniel Shead <nathanieloshead@gmail.com>2025-05-10 01:12:20 +1000
committerNathaniel Shead <nathanieloshead@gmail.com>2025-05-14 19:26:24 +1000
commit011ea36d0e5828e9db848f4a46b9a17f634ed2c0 (patch)
treefc0691327ebb5617077bda29d8ecd9a494788147
parent3ecca8f3ad7e7fe3da0e600fb66fca3dc6bae006 (diff)
downloadgcc-011ea36d0e5828e9db848f4a46b9a17f634ed2c0.zip
gcc-011ea36d0e5828e9db848f4a46b9a17f634ed2c0.tar.gz
gcc-011ea36d0e5828e9db848f4a46b9a17f634ed2c0.tar.bz2
c++/modules: Revert "Remove unnecessary lazy_load_pendings"
This reverts commit r16-63-g241157eb0858b3. It turns out that the 'lazy_load_pendings' is necessary if we haven't seen a binding for the given template name at all in the current TU, as it is also used to find template instantiations with the given name. gcc/cp/ChangeLog: * name-lookup.cc (lookup_imported_hidden_friend): Add back lazy_load_pendings with comment. gcc/testsuite/ChangeLog: * g++.dg/modules/tpl-friend-19_a.C: New test. * g++.dg/modules/tpl-friend-19_b.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
-rw-r--r--gcc/cp/name-lookup.cc3
-rw-r--r--gcc/testsuite/g++.dg/modules/tpl-friend-19_a.C16
-rw-r--r--gcc/testsuite/g++.dg/modules/tpl-friend-19_b.C6
3 files changed, 25 insertions, 0 deletions
diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 9b317c4..84b5e67 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -4556,6 +4556,9 @@ lookup_imported_hidden_friend (tree friend_tmpl)
|| !DECL_MODULE_ENTITY_P (inner))
return NULL_TREE;
+ /* Load any templates matching FRIEND_TMPL from importers. */
+ lazy_load_pendings (friend_tmpl);
+
tree name = DECL_NAME (inner);
tree *slot = find_namespace_slot (current_namespace, name, false);
if (!slot || !*slot || TREE_CODE (*slot) != BINDING_VECTOR)
diff --git a/gcc/testsuite/g++.dg/modules/tpl-friend-19_a.C b/gcc/testsuite/g++.dg/modules/tpl-friend-19_a.C
new file mode 100644
index 0000000..59f0175
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/tpl-friend-19_a.C
@@ -0,0 +1,16 @@
+// { dg-additional-options "-fmodules -Wno-global-module" }
+// { dg-module-cmi M }
+
+module;
+
+template <typename _MemFunPtr>
+class _Mem_fn_base {
+ template <typename> friend struct _Bind_check_arity;
+};
+
+template <typename> struct _Bind_check_arity {};
+
+export module M;
+
+template struct _Bind_check_arity<int>;
+export _Mem_fn_base<int> mem_fn();
diff --git a/gcc/testsuite/g++.dg/modules/tpl-friend-19_b.C b/gcc/testsuite/g++.dg/modules/tpl-friend-19_b.C
new file mode 100644
index 0000000..ce99647
--- /dev/null
+++ b/gcc/testsuite/g++.dg/modules/tpl-friend-19_b.C
@@ -0,0 +1,6 @@
+// { dg-additional-options "-fmodules" }
+
+import M;
+int main() {
+ mem_fn();
+}