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

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:3e0768d2ffde3f20c5baa92d33869f0c196245c4

commit r15-8967-g3e0768d2ffde3f20c5baa92d33869f0c196245c4
Author: Nathaniel Shead <nathanielosh...@gmail.com>
Date:   Thu Mar 27 00:23:24 2025 +1100

    c++/modules: Fix tsubst of global module friend classes [PR118920]

    When doing tsubst_friend_class, we need to first check if any imported
    module has already created a (hidden) declaration for the class so that
    we don't end up with conflicting declarations.  Currently we do this
    using DECL_MODULE_IMPORT_P, but this is not set in cases where the class
    is in the global module and matches an existing GM declaration we've
    seen (via an include, for example).

    This patch fixes this by checking DECL_MODULE_ENTITY_P instead, which is
    set on all entities that have been seen from a module import.  We also
    use the 'for_mangle' version of get_originating_module so that we don't
    treat imported GM entities as attached to the module we imported them
    from.  And rename that parameter to something more general.

    And dump_module_suffix is another place where we want to treat global
module
    entities as not coming from a module.

            PR c++/118920

    gcc/cp/ChangeLog:

            * name-lookup.cc (lookup_imported_hidden_friend): Check for
            module entity rather than just module import.
            * module.cc (get_originating_module): Rename for_mangle parm to
            global_m1.
            * error.cc (dump_module_suffix): Don't decorate global module
decls.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/tpl-friend-17.h: New test.
            * g++.dg/modules/tpl-friend-17_a.C: New test.
            * g++.dg/modules/tpl-friend-17_b.C: New test.

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

Reply via email to