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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Nathan Sidwell <nat...@gcc.gnu.org>:

https://gcc.gnu.org/g:83bdc9f70347e6438822e719c30c3793c81df18e

commit r11-6983-g83bdc9f70347e6438822e719c30c3793c81df18e
Author: Nathan Sidwell <nat...@acm.org>
Date:   Fri Jan 29 08:30:40 2021 -0800

    c++: Fix unordered entity array [PR 98843]

    A couple of module invariants are that the modules are always
    allocated in ascending order and appended to the module array.  The
    entity array is likewise ordered, with each module having spans in
    that array in ascending order.  Prior to header-units, this was
    provided by the way import declarations were encountered.  With
    header-units we need to load the preprocessor state of header units
    before we parse the C++, and this can lead to incorrect ordering of
    the entity array.  I had made the initialization of a module's
    language state a little too lazy.  This moves the allocation of entity
    array spans into the initial read of a module, thus ensuring the
    ordering of those spans.  We won't be looking in them until we've
    loaded the language portions of that particular module, and even if we
    did, we'd find NULLs there and issue a diagnostic.

            PR c++/98843
            gcc/cp/
            * module.cc (module_state_config): Add num_entities field.
            (module_state::read_entities): The entity_ary span is
            already allocated.
            (module_state::write_config): Write num_entities.
            (module_state::read_config): Read num_entities.
            (module_state::write): Set config's num_entities.
            (module_state::read_initial): Allocate the entity ary
            span here.
            (module_state::read_language): Do not set entity_lwm
            here.
            gcc/testsuite/
            * g++.dg/modules/pr98843_a.C: New.
            * g++.dg/modules/pr98843_b.H: New.
            * g++.dg/modules/pr98843_c.C: New.

Reply via email to