[Bug c++/122279] Non-exported using-directives not visible across TUs within the same module

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat Oct 18 14:11:35 GMT 2025


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

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

https://gcc.gnu.org/g:515045254f5dbdea5208035a0352acc12c381088

commit r16-4484-g515045254f5dbdea5208035a0352acc12c381088
Author: Nathaniel Shead <nathanieloshead@gmail.com>
Date:   Wed Oct 15 18:13:38 2025 +1100

    c++/modules: Import purview using-directives in the same module [PR122279]

    [namespace.qual] p1 says that a namespace nominated by a using-directive
    is searched if the using-directive precedes that point.

    [basic.lookup.general] p2 says that a declaration in a different TU
    within a module purview is visible if either the declaration is
    exported, or the other TU is part of the same module as the point of
    lookup.  This patch implements the second half of that.

            PR c++/122279

    gcc/cp/ChangeLog:

            * module.cc (depset::hash::add_namespace_entities): Seed any
            purview using-decls.
            (module_state::write_using_directives): Stream if the udir was
            exported or not.
            (module_state::read_using_directives): Add the using-directive
            if it's either exported or part of this module.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/namespace-13_b.C: Adjust expected results.
            * g++.dg/modules/namespace-13_c.C: Test non-exported
            using-directive is not used.
            * g++.dg/modules/namespace-14_a.C: New test.
            * g++.dg/modules/namespace-14_b.C: New test.
            * g++.dg/modules/namespace-14_c.C: New test.
            * g++.dg/modules/namespace-14_d.C: New test.

    Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
    Reviewed-by: Patrick Palka <ppalka@redhat.com>
    Reviewed-by: Jason Merrill <jason@redhat.com>


More information about the Gcc-bugs mailing list