diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 2dca57a14fd832d5fb1d1224c535563be16af678..769879976420db7ab74c2e4b7fb51f5c2bf28258 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -4569,6 +4569,8 @@ lookup_imported_hidden_friend (tree friend_tmpl)
       || !DECL_MODULE_IMPORT_P (inner))
     return NULL_TREE;
 
+  lazy_load_pendings (friend_tmpl);
+
   tree bind = get_mergeable_namespace_binding
     (current_namespace, DECL_NAME (inner), DECL_MODULE_ATTACH_P (inner));
   if (!bind)