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

--- Comment #11 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:4cd99e41ef687fd62d6908f4807de277c7dc9803

commit r15-8012-g4cd99e41ef687fd62d6908f4807de277c7dc9803
Author: Nathaniel Shead <nathanielosh...@gmail.com>
Date:   Mon Mar 10 23:35:40 2025 +1100

    c++/modules: Handle gnu_inline attribute, cleanup linkage determination
[PR119154]

    Currently, note_vague_linkage_fn is called on all definitions imported
    from modules.  This is not correct, however; among other things, a
    gnu_inline function does not have vague linkage, and causes an ICE if
    its treated as such.

    There are other things that we seem to potentially miss (e.g. dllexport
    handling), so it seems sensible to stop trying to manage linkage in such
    an ad-hoc manner but to use the normal interfaces more often.  While
    looking at this I also found that we seem to miss marking vague linkage
    variables as COMDAT, so this patch fixes that as well.

    The change to use expand_or_defer_fn exposes a checking-only ICE in
    trees_in::assert_definition, where we forget that we already installed a
    definition for a function.  We work around this by instead of clearing
    DECL_SAVED_TREE entirely in expand_or_defer_fn_1, we instead set it to a
    dummy value.  This way we can also avoid the check for !TREE_ASM_WRITTEN
    beforehand.

            PR c++/119154

    gcc/cp/ChangeLog:

            * decl2.cc (vague_linkage_p): Don't treat gnu_inline functions
            as having vague linkage.
            * module.cc (trees_out::core_bools): Clear DECL_INTERFACE_KNOWN
            for vague-linkage entities.
            (read_var_def): Maybe set comdat linkage for imported var
            definitions.
            (module_state::read_cluster): Use expand_or_defer_fn instead of
            ad-hoc linkage management.
            (post_load_processing): Likewise.
            * semantics.cc (expand_or_defer_fn_1): Don't forget that we had
            a definition at all.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/linkage-3_a.C: New test.
            * g++.dg/modules/linkage-3_b.C: New test.
            * g++.dg/modules/pr119154_a.C: New test.
            * g++.dg/modules/pr119154_b.C: New test.

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

Reply via email to