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

--- Comment #6 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:ca287145f23ec3ea987fc2eacde3994096cc528e

commit r15-2779-gca287145f23ec3ea987fc2eacde3994096cc528e
Author: Nathaniel Shead <nathanielosh...@gmail.com>
Date:   Sat Jun 15 22:50:14 2024 +1000

    c++/modules: Ensure deduction guides are always reachable [PR115231]

    Deduction guides are represented as 'normal' functions currently, and
    have no special handling in modules.  However, this causes some issues;
    by [temp.deduct.guide] a deduction guide is not found by normal name
    lookup and instead all reachable deduction guides for a class template
    should be considered, but this does not happen currently.

    To solve this, this patch ensures that all deduction guides are
    considered exported to ensure that they are always visible to importers
    if they are reachable.  Another alternative here would be to add a new
    kind of "all reachable" flag to name lookup, but that is complicated by
    some difficulties in handling GM entities; this may be a better way to
    go if more kinds of entities end up needing this handling, however.

    Another issue here is that because deduction guides are "unrelated"
    functions, they will usually get discarded from the GMF, so this patch
    ensures that when finding dependencies, GMF deduction guides will also
    have bindings created.  We do this in find_dependencies so that we don't
    unnecessarily create bindings for GMF deduction guides that are never
    reached; for consistency we do this for *all* deduction guides, not just
    GM ones.  We also make sure that the opposite (a deduction guide being
    the only purview reference to a GMF template) correctly marks it as
    reachable.

    Finally, when merging deduction guides from multiple modules, the name
    lookup code may now return two-dimensional overload sets, so update
    callers to match.

    As a small drive-by improvement this patch also updates the error pretty
    printing code to add a space before the '->' when printing a deduction
    guide, so we get 'S(int) -> S<int>' instead of 'S(int)-> S<int>'.

            PR c++/115231

    gcc/cp/ChangeLog:

            * error.cc (dump_function_decl): Add a space before '->' when
            printing deduction guides.
            * module.cc (depset::hash::add_binding_entity): Don't create
            bindings for guides here, only mark dependencies.
            (depset::hash::add_deduction_guides): New.
            (depset::hash::find_dependencies): Add deduction guide
            dependencies for a class template.
            (module_state::write_cluster): Always consider deduction guides
            as exported.
            * pt.cc (deduction_guides_for): Use 'lkp_iterator' instead of
            'ovl_iterator'.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/dguide-1_a.C: New test.
            * g++.dg/modules/dguide-1_b.C: New test.
            * g++.dg/modules/dguide-2_a.C: New test.
            * g++.dg/modules/dguide-2_b.C: New test.
            * g++.dg/modules/dguide-3_a.C: New test.
            * g++.dg/modules/dguide-3_b.C: New test.
            * g++.dg/modules/dguide-3_c.C: New test.
            * g++.dg/modules/dguide-3_d.C: New test.

    Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>
  • [Bug c++/115231] [C++20] [Modul... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to