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

--- Comment #3 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:c2e567a6edb563677107c40ce2ce67f78d294013

commit r16-3559-gc2e567a6edb563677107c40ce2ce67f78d294013
Author: Nathaniel Shead <nathanielosh...@gmail.com>
Date:   Sun Aug 24 01:56:32 2025 +1000

    c++/modules: Fix ADL [PR117658]

    On looking again at [basic.lookup.argdep] p4, I believe GCC hasn't fully
    implemented the wording here for ADL.  This patch fixes two issues.

    First, 4.3 indicates that a function exported from a named module should
    be visible to ADL regardless of whether it's visible to normal name
    lookup, as long as some restrictions are followed.

    This patch implements this; for skipping declarations that "do not
    appear in the TU containing the point of lookup" I don't think there's
    anything special we need to do, as any declarations before the point of
    lookup will be found in other ways anyway, and any remaining
    declarations from the current TU cannot be seen regardless.

    Secondly, currently we only add the exported functions along the
    instantiation path of a lookup.  But I don't think this is intended by
    the current wording, so this patch adjusts that.  I also clean up the
    logic to do all different module processing in adl_namespace_fns so that
    we don't duplicate work in traversing the module binding list
    unnecessarily.

    This new handling means we need to do some extra work to properly error
    on overload sets containing TU-local entities (as this might actually
    come up now!) but I'm leaving that for a later patch.

    As a drive-by fix this also fixes an ICE for C++26 expansion statements
    with finding the instantiation path.

            PR c++/117658

    gcc/cp/ChangeLog:

            * cp-tree.h (get_originating_module): Adjust parameter names.
            * module.cc (path_of_instantiation): Handle C++26 expansion
            statements.
            * name-lookup.cc (name_lookup::adl_namespace_fns): Handle
            exported declarations attached to the same module of an
            associated entity with the same innermost non-inline namespace,
            and non-exported functions on the instantiation path.
            (name_lookup::search_adl): Build mapping of namespace to modules
            that associated entities are attached to; remove now-unneeded
            instantiation path handling.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/adl-4_a.C: Test should pass.
            * g++.dg/modules/adl-4_b.C: Test should pass.
            * g++.dg/modules/adl-6_a.C: New test.
            * g++.dg/modules/adl-6_b.C: New test.
            * g++.dg/modules/adl-6_c.C: New test.
            * g++.dg/modules/adl-7_a.C: New test.
            * g++.dg/modules/adl-7_b.C: New test.
            * g++.dg/modules/adl-7_c.C: New test.
            * g++.dg/modules/adl-8_a.C: New test.
            * g++.dg/modules/adl-8_b.C: New test.
            * g++.dg/modules/adl-8_c.C: New test.

    Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>
    Reviewed-by: Jason Merrill <ja...@redhat.com>
  • [Bug c++/117658] Different ADL ... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to