c++: visibility of instantiated template friends
authorJason Merrill <jason@redhat.com>
Fri, 22 Nov 2024 15:05:51 +0000 (16:05 +0100)
committerJason Merrill <jason@redhat.com>
Fri, 9 May 2025 20:32:12 +0000 (16:32 -0400)
In 20_util/variant/visit_member.cc, instantiation of the variant friend
declaration of __get for variant<test01()::X> was being marked as internal
because that variant specialization is itself internal.  And therefore
check_module_override didn't try to merge it with the non-exported
namespace-scope declaration of __get.

But the template parms of variant are not part of the friend template's
identity, so they should not affect its visibility.  If they are substituted
into the friend declaration, we'll handle that when looking at the
declaration itself.

This change no longer seems necessary to fix the testcase, but does still
seem correct.  We definitely still get here during tsubst_friend_function.

gcc/cp/ChangeLog:

* decl2.cc (determine_visibility): Ignore args for friend templates.

gcc/cp/decl2.cc

index 21156f1dd3b7a6ba40cc389a61229b4c1d25931d..15db1d657341dfeeae68bfc0d574a063c184b382 100644 (file)
@@ -3160,7 +3160,9 @@ determine_visibility (tree decl)
              && !attr)
            {
              int depth = TMPL_ARGS_DEPTH (args);
-             if (DECL_VISIBILITY_SPECIFIED (decl))
+             if (DECL_UNINSTANTIATED_TEMPLATE_FRIEND_P (TI_TEMPLATE (tinfo)))
+               /* Class template args don't affect template friends.  */;
+             else if (DECL_VISIBILITY_SPECIFIED (decl))
                {
                  /* A class template member with explicit visibility
                     overrides the class visibility, so we need to apply
This page took 0.067846 seconds and 5 git commands to generate.