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

--- Comment #12 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Patrick Palka
<ppa...@gcc.gnu.org>:

https://gcc.gnu.org/g:648db321893acabd06c24da149c09fceab4daeff

commit r12-8995-g648db321893acabd06c24da149c09fceab4daeff
Author: Patrick Palka <ppa...@redhat.com>
Date:   Sat Dec 3 10:28:25 2022 -0500

    c++: substituting CONST_DECL_USING_P enumerators [PR103081]

    We implement class-scope using enum by injecting clones of the enum's
    CONST_DECLs as fields of the class, for which CONST_DECL_USING_P is
    true, so that qualified lookup naturally finds the enumerators.
    Substitution into such a CONST_DECL currently ICEs however, because we
    assume the DECL_CONTEXT is always the ENUMERAL_TYPE (which has
    TYPE_VALUES) but in this case it's the RECORD_TYPE for the class scope
    (which has TYPE_FIELDS).

    Since these CONST_DECLs appear to always be non-dependent, this patch
    fixes this by shortcutting substitution for CONST_DECLs that have
    non-dependent DECL_CONTEXT.  This subsumes the existing (and seemingly
    dead) DECL_NAMESPACE_SCOPE_P early exit test and also benefits
    substitution into ordinary non-dependent CONST_DECLs.

            PR c++/103081

    gcc/cp/ChangeLog:

            * pt.cc (tsubst_copy) <case CONST_DECL>: Generalize
            early exit test for namespace-scope decls to check dependence of
            the enclosing scope instead.  Remove dead early exit test.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/using-enum-10.C: New test.
            * g++.dg/cpp2a/using-enum-10a.C: New test.

    (cherry picked from commit b3912122c9dfaba6c8229e8f095885f69782ceda)

Reply via email to