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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>:

https://gcc.gnu.org/g:f5c1224708a0cf9cc2770c44bbbe7d0c883942be

commit r14-9374-gf5c1224708a0cf9cc2770c44bbbe7d0c883942be
Author: Patrick Palka <ppa...@redhat.com>
Date:   Thu Mar 7 16:39:20 2024 -0500

    c++/modules: member alias tmpl partial inst [PR103994]

    Alias templates are weird in that their specializations can appear in
    both decl_specializations and type_specializations.  They're always in
    the decl table, and additionally appear in the type table only at parse
    time via finish_template_type.  There seems to be no good reason for
    them to appear in both tables, and the code paths end up stepping over
    each other in particular for a partial instantiation such as
    A<B>::key_arg<T> in the below modules testcase: the type code path
    (lookup_template_class) wants to set TI_TEMPLATE to the most general
    template whereas the decl code path (tsubst_template_decl called during
    instantiation of A<B>) already set TI_TEMPLATE to the partially
    instantiated TEMPLATE_DECL.  This TI_TEMPLATE change ends up confusing
    modules which decides to stream the logically equivalent TYPE_DECL and
    TEMPLATE_DECL for this partial instantiation separately.

    This patch fixes this by making lookup_template_class dispatch to
    instantiate_alias_template early for alias template specializations.
    In turn we now add such specializations only to the decl table.  This
    admits some nice simplification in the modules code which otherwise has
    to cope with such specializations appearing in both tables.

            PR c++/103994

    gcc/cp/ChangeLog:

            * cp-tree.h (add_mergeable_specialization): Remove second
            parameter.
            * module.cc (depset::disc_bits::DB_ALIAS_TMPL_INST_BIT): Remove.
            (depset::disc_bits::DB_ALIAS_SPEC_BIT): Remove.
            (depset::is_alias_tmpl_inst): Remove.
            (depset::is_alias): Remove.
            (merge_kind::MK_tmpl_alias_mask): Remove.
            (merge_kind::MK_alias_spec): Remove.
            (merge_kind_name): Remove entries for alias specializations.
            (trees_out::core_vals) <case TEMPLATE_DECL>: Adjust after
            removing is_alias_tmpl_inst.
            (trees_in::decl_value): Adjust add_mergeable_specialization
            calls.
            (trees_out::get_merge_kind) <case depset::EK_SPECIALIZATION>:
            Use MK_decl_spec for alias template specializations.
            (trees_out::key_mergeable): Simplify after MK_tmpl_alias_mask
            removal.
            (depset::hash::make_dependency): Adjust after removing
            DB_ALIAS_TMPL_INST_BIT.
            (specialization_add): Don't allow alias templates when !decl_p.
            (depset::hash::add_specializations): Remove now-dead code
            accomodating alias template specializations in the type table.
            * pt.cc (lookup_template_class): Dispatch early to
            instantiate_alias_template for alias templates.  Simplify
            accordingly.
            (add_mergeable_specialization): Remove alias_p parameter and
            simplify accordingly.

    gcc/testsuite/ChangeLog:

            * g++.dg/modules/pr99425-1_b.H: s/alias/decl in dump scan.
            * g++.dg/modules/tpl-alias-1_a.H: Likewise.
            * g++.dg/modules/tpl-alias-2_a.H: New test.
            * g++.dg/modules/tpl-alias-2_b.C: New test.

    Reviewed-by: Jason Merrill <ja...@redhat.com>

Reply via email to