https://gcc.gnu.org/g:3c7c2a6b86da641f7729dba89b25fc1b8b74d96f

commit r16-504-g3c7c2a6b86da641f7729dba89b25fc1b8b74d96f
Author: Jason Merrill <ja...@redhat.com>
Date:   Fri Nov 22 16:05:51 2024 +0100

    c++: visibility of instantiated template friends
    
    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.

Diff:
---
 gcc/cp/decl2.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc
index 21156f1dd3b7..15db1d657341 100644
--- a/gcc/cp/decl2.cc
+++ b/gcc/cp/decl2.cc
@@ -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

Reply via email to