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

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

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

commit r17-7104-ge0d5b2cba1358c58fc365066fbfc151cb28d93c6
Author: Marek Polacek <[email protected]>
Date:   Tue Dec 1 16:56:25 2026 -0500

    c++/reflection: reflection and partial ordering [PR129115]

    This patch fixes two problems related to splices in templates.

    First, when we have

      template<typename T> int f (typename [: ^^T :] x);
      template<typename T> int f (typename [: ^^T :] x) { return 1; }

    the two decls should be merged in duplicate_decls, but are not.  That's
    because decls_match -> compparms -> structural_comptypes doesn't handle
    the parameters correctly: make_splice_scope sets each SPLICE_SCOPE as its
    own canonical type, so equivalent splices compared unequal.  So, we should
    use structural equality for splices, not comparing canonical nodes.  And so
    structural_comptypes needs to handle SPLICE_SCOPEs.

    Second, [temp.deduct.type]/5 lists a splice-specifier as a non-deduced
    context.  This fixes a crash in unify when we actually have to perform
    partial ordering.  Also adjust for_each_template_parm_r by adding a case
    for SPLICE_EXPR.  The SPLICE_SCOPE case remains as-is: only the
    splice-specifier is non-deduced, so T in typename [: R :]<T> must still
    be found.

    This patch does not fix the modules ICE:
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129115#c2
    that should be fixed separately.

    In diag2.C, the two rs now have the same type, so the error changed.

            PR c++/129115

    gcc/cp/ChangeLog:

            * pt.cc (for_each_template_parm_r): Handle SPLICE_EXPR as
            non-deduced context.
            (unify): Handle SPLICE_SCOPE.
            * reflect.cc (make_splice_scope): SET_TYPE_STRUCTURAL_EQUALITY.
            * typeck.cc (structural_comptypes): Handle SPLICE_SCOPE.

    gcc/testsuite/ChangeLog:

            * g++.dg/reflect/diag2.C: Adjust expected diagnostic.
            * g++.dg/reflect/member26.C: New test.
            * g++.dg/reflect/partial-ordering1.C: New test.
            * g++.dg/reflect/partial-ordering2.C: New test.
            * g++.dg/reflect/partial-specialization1.C: New test.
            * g++.dg/reflect/partial-specialization2.C: New test.

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

Reply via email to