https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125555
--- Comment #5 from Patrick Palka <ppalka at gcc dot gnu.org> ---
I arrived at something kinda similar:
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -15449,7 +15449,8 @@ depset::hash::add_specializations (bool decl_p)
int use_tpl = 0;
bool is_friend = false;
- if (decl_p && DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P (entry->tmpl))
+ if (decl_p && DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P (entry->tmpl)
+ && !DECL_UNIQUE_FRIEND_P (STRIP_TEMPLATE (entry->tmpl)))
/* A friend of a template. This is keyed to the
instantiation. */
is_friend = true;
i.e. don't set is_friend = true for unique friends, which notably means we
don't set the DB_FRIEND_SPEC_BIT for its depset. It seems to mostly work, the
only testsuite regression is friend-13.C:
module;
template <typename T> struct tuple {
template <typename U> friend void f(tuple, U) { }
};
template <typename T> tuple<T> make_unique();
export module M;
void test() {
auto lambda = [] {};
make_unique<decltype(lambda)>();
}
where we ICE on the assert in import_entity_index for the TYPE_DECL for the
lambda's closure type. That's as far as I got.