https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121705

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathaniel Shead <nsh...@gcc.gnu.org>:

https://gcc.gnu.org/g:c39dbb652fafbb06507d23dcec6627ac9a9398cf

commit r16-3612-gc39dbb652fafbb06507d23dcec6627ac9a9398cf
Author: Nathaniel Shead <nathanielosh...@gmail.com>
Date:   Sun Aug 31 14:47:43 2025 +1000

    c++/modules: Support ADL on non-discarded GM entities [PR121705]

    [basic.lookup.argdep] p4 says that ADL also finds declarations of
    functions or function templates from a point of lookup within the
    module, only ignoring discarded (or internal) GM entities.

    To implement this we need to create bindings for these entities so that
    we can guarantee that name lookup will discover they exist.  This raises
    some complications, though, as we ideally would like to avoid having
    bindings that contain no declarations, or emitting GM namespaces that
    only contain discarded or internal functions.

    This patch does this by additionally creating a new binding whenever we
    call make_dependency on a non-EK_FOR_BINDING decl.  We don't do this for
    using-decls, as at the point of use of a GM entity we no longer know
    whether we called through a using-decl or the declaration directly;
    however, this behaviour is explicitly supported by [module.global.frag]
    p3.6.

    Creating these bindings caused g++.dg/modules/default-arg-4_* to fail.
    It turns out that this makes the behaviour look identical to
    g++.dg/modules/default-arg-5, which is incorrectly dg-error-ing default
    value redeclarations (we only currently error because of PR c++/99000).
    This patch removes the otherwise identical test and turns the dg-errors
    into xfailed dg-bogus.

    As a drive-by fix this also fixes an ICE when debug printing friend
    function instantiations.

            PR c++/121705
            PR c++/117658

    gcc/cp/ChangeLog:

            * module.cc (depset::hash::make_dependency): Make bindings for
            GM functions.
            (depset::hash::add_binding_entity): Adjust comment.
            (depset::hash::add_deduction_guides): Add log.
            * ptree.cc (cxx_print_xnode): Handle friend functions where
            TI_TEMPLATE is an OVERLOAD or IDENTIFIER.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/default-arg-4_a.C: XFAIL bogus errors.
            * g++.dg/modules/default-arg-4_b.C: Likewise.
            * g++.dg/modules/default-arg-5_a.C: Remove duplicate test.
            * g++.dg/modules/default-arg-5_b.C: Likewise.
            * g++.dg/modules/adl-9_a.C: New test.
            * g++.dg/modules/adl-9_b.C: New test.
            * g++.dg/modules/gmf-5.C: New test.

    Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>
    Reviewed-by: Jason Merrill <ja...@redhat.com>

Reply via email to