Tested x86_64-pc-linux-gnu, applying to trunk. -- 8< --
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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index 21156f1dd3b..15db1d65734 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 base-commit: 21842fe301caa5dbc69a69033cdc17bb29b8c399 -- 2.49.0