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

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

https://gcc.gnu.org/g:5258acb60d81e532814275fccb50cec98ca17fc7

commit r16-8066-g5258acb60d81e532814275fccb50cec98ca17fc7
Author: Nathaniel Shead <[email protected]>
Date:   Mon Mar 9 01:10:02 2026 +1100

    c++/modules: Reparent linemaps for partition direct loads [PR124309]

    The attached testcase failed because when part-11_d.C sees the import
    of X through Z:part, the module's location is maintained as the indirect
    (imported) location through Y that came first, but it is still promoted
    to a direct import.

    When part-11_e.C reads the module then it sees a direct import of X
    through Z, but there is no valid source location for X in Z (because we
    only kept the imported location) and so we report a bad CMI.

    This fixes the issue by updating a module seen as direct for the first
    time via a partition to reparent the module's location to where the
    partition imported it from, so we properly process it as a direct
    location that we need to write out, similarly to what we do when we
    reimport an indirect module within the module purview.

            PR c++/124309

    gcc/cp/ChangeLog:

            * module.cc (enum module_directness): Fix inconsistent
            capitalisation.
            (module_state::read_imports): Reparent module locations newly
            seen as direct via partition.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/part-11_a.C: New test.
            * g++.dg/modules/part-11_b.C: New test.
            * g++.dg/modules/part-11_c.C: New test.
            * g++.dg/modules/part-11_d.C: New test.
            * g++.dg/modules/part-11_e.C: New test.

    Signed-off-by: Nathaniel Shead <[email protected]>
    Reviewed-by: Jason Merrill <[email protected]>

Reply via email to