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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Jason Merrill <[email protected]>:

https://gcc.gnu.org/g:719156070f5f5f9070a4d9b736c238b5d028f719

commit r17-1259-g719156070f5f5f9070a4d9b736c238b5d028f719
Author: feedable <[email protected]>
Date:   Wed Jun 3 08:40:53 2026 -0400

    c++/reflection: member function template splicing [PR124794]

    cp_parser_splice_expression is stripping BASELINKs before resolving the
    expr; checks if the result is a BASELINK after that (by which point it
never
    is).  To fix it, stop stripping the BASELINK, add handling to
    check_splice_expr instead.

    In cp_parser_splice_specifier, the additional template param parsing fails
    to detect that the reflection is a template if it's wrapped in a BASELINKs,
    and decides not to parse the splice-specialization-specifier if the
    'template' keyword is missing. Grab the data from the reflection instead.

    During template instantiation, we blindly substitute the template part of a
    TEMPLATE_ID_EXPR, even if it's a SPLICE_EXPR. This, in turn, substitutes
the
    SPLICE_EXPR as-if it had no template arguments and finishes up the
    expression, which interferes with later processing by TEMPLATE_ID_EXPR.  To
    fix, we defer such TEMPLATE_ID_EXPRs to tsubst_splice_expr, which itself
    performs the substitution of a TEMPLATE_ID_EXPR and finishes up the
    expression.

    check_splice_expr now also accepts TEMPLATE_ID_EXPRs in tsubst_splice_expr;
    this is uniform with cp_parser_splice_expression, and required in order to
    handle `template[:dep:]<>` where `dep` does not reflect a template.

            PR c++/124794
            PR c++/125069

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_splice_specifier): Do not strip BASELINKs.
            (cp_parser_splice_expression): Add parsing for member function
            template specializations without the "template" keyword.
            * pt.cc (tsubst_splice_expr): Handle TEMPLATE_ID_EXPR where the
            template part is a SPLICE_EXPR.
            (tsubst_expr): Defer to tsubst_splice_expr when the template part
of
            TEMPLATE_ID_EXPR is a SPLICE_EXPR.
            * reflect.cc (check_splice_expr): Add handling for BASELINKs.

    gcc/testsuite/ChangeLog:

            * g++.dg/reflect/member19.C: Enable tests.
            * g++.dg/reflect/splice15.C: New test.
            * g++.dg/reflect/splice16.C: New test.

    Reviewed-by: Jason Merrill <[email protected]>

Reply via email to