https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125555
--- Comment #8 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Ah but presumably we want to treat instantiations of a non-template friends vs
template friends consistently, which the TI_TEMPLATE (ti) != entry->tmpl check
won't do. For non-template friend instantiations the check will always be
false, and we'll never record any (full) specializations of non-template
(hidden) friends.
I think this would consistently set is_friend=false on full specializations of
template and non-template friends:
--- a/gcc/cp/module.cc
+++ b/gcc/cp/module.cc
@@ -15468,9 +15468,10 @@ depset::hash::add_specializations (bool decl_p)
}
else if (is_friend)
{
- if (TI_TEMPLATE (ti) != entry->tmpl
- || !template_args_equal (TI_ARGS (ti), entry->tmpl))
+ if (TREE_CODE (spec) == TEMPLATE_DECL)
goto template_friend;
+ else
+ is_friend = false;
}
}
else
but it regresses a modified a non-template friend version of friend-13.C:
diff --git a/gcc/testsuite/g++.dg/modules/friend-13.C
b/gcc/testsuite/g++.dg/modules/friend-13.C
index 8930eca7ded5..7fe24bafb218 100644
--- a/gcc/testsuite/g++.dg/modules/friend-13.C
+++ b/gcc/testsuite/g++.dg/modules/friend-13.C
@@ -4,7 +4,7 @@
module;
template <typename T> struct tuple {
- template <typename U> friend void f(tuple, U);
+ friend void f(tuple, int) { }
};
template <typename T> tuple<T> make_unique();
export module M;
gcc/testsuite/g++.dg/modules/friend-13.C:10:8: internal compiler error: in
import_entity_index, at cp/module.cc:4337
While perhaps not fully correct/consistent, the TI_TEMPLATE (ti) != entry->tmpl
check seems strictly better than the current buggy code which ignores all
friend specializations, so perhaps we should go with it for now?