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

--- Comment #3 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:3685fae23bb00898749dfc155212c9c5cd3a0980

commit r14-9232-g3685fae23bb00898749dfc155212c9c5cd3a0980
Author: Nathaniel Shead <nathanielosh...@gmail.com>
Date:   Fri Feb 16 15:52:48 2024 +1100

    c++: Support lambdas attached to more places in modules [PR111710]

    The fix for PR107398 weakened the restrictions that lambdas must belong
    to namespace scope. However this was not sufficient: we also need to
    allow lambdas attached to FIELD_DECLs, PARM_DECLs, and TYPE_DECLs.

    For field decls we key the lambda to its class rather than the field
    itself. Otherwise we can run into issues when deduplicating the lambda's
    TYPE_DECL, because when loading its context we load the containing field
    before we've deduplicated the keyed lambda, causing mismatches; by
    keying to the class instead we defer checking keyed declarations until
    deduplication has completed.

    Additionally, by [basic.link] p15.2 a lambda defined anywhere in a
    class-specifier should not be TU-local, which includes base-class
    declarations, so ensure that lambdas declared there are keyed
    appropriately as well.

    Because this now requires 'DECL_MODULE_KEYED_DECLS_P' to be checked on a
    fairly large number of different kinds of DECLs, and that in general
    it's safe to just get 'false' as a result of a check on an unexpected
    DECL type, this patch also removes the tree checking from the accessor.

    Finally, to handle deduplicating templated lambda fields, we need to
    ensure that we can determine that two lambdas from different field decls
    match, so we ensure that we also deduplicate LAMBDA_EXPRs on stream in.

            PR c++/111710

    gcc/cp/ChangeLog:

            * cp-tree.h (DECL_MODULE_KEYED_DECLS_P): Remove tree checking.
            (struct lang_decl_base): Update comments and fix whitespace.
            * module.cc (trees_out::lang_decl_bools): Always write
            module_keyed_decls_p flag...
            (trees_in::lang_decl_bools): ...and always read it.
            (trees_out::decl_value): Handle all kinds of keyed decls.
            (trees_in::decl_value): Likewise.
            (trees_in::tree_value): Deduplicate LAMBDA_EXPRs.
            (maybe_key_decl): Also support lambdas attached to fields,
            parameters, and types. Key lambdas attached to fields to their
            class.
            (trees_out::get_merge_kind): Likewise.
            (trees_out::key_mergeable): Likewise.
            (trees_in::key_mergeable): Support keyed decls in a TYPE_DECL
            container.
            * parser.cc (cp_parser_class_head): Start a lambda scope when
            parsing base classes.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/lambda-7.h: New test.
            * g++.dg/modules/lambda-7_a.H: New test.
            * g++.dg/modules/lambda-7_b.C: New test.
            * g++.dg/modules/lambda-7_c.C: New test.

    Signed-off-by: Nathaniel Shead <nathanielosh...@gmail.com>
    Reviewed-by: Patrick Palka <ppa...@redhat.com>
    Reviewed-by: Jason Merrill <ja...@redhat.com>
  • [Bug c++/111710] [modules] ICE ... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to