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

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

https://gcc.gnu.org/g:121235441d072c2f5fd4d2cc0c342d45d6ac481f

commit r15-10173-g121235441d072c2f5fd4d2cc0c342d45d6ac481f
Author: Patrick Palka <ppa...@redhat.com>
Date:   Thu Jun 5 11:07:25 2025 -0400

    c++: substituting fn parm redeclared with dep alias tmpl [PR120224]

    Here we declare f twice, the second time around using a dependent
    alias template.  Due to alias template transparency these are logically
    the same overload.  But now the function type of f (produced from the
    first declaration) diverges from the type of its formal parameter
    (produced from the subsequent redefinition) in that substituting T=int
    succeeds for the function type but not for the formal parameter type.
    This eventually causes us to produce an undiagnosed error_mark_node in
    the AST of the function call, leading to failure of the sanity check
    check added in r14-6343-g0c018a74eb1aff.

    Before r14-6343 we would still go on to reject the testcase later at
    instantiation time, from regenerate_decl_from_template, making this a
    regression.

    To fix this, it seems we just need to propagate error_mark_node upon
    substitution failure into the type of a PARM_DECL.

            PR c++/120224

    gcc/cp/ChangeLog:

            * pt.cc (tsubst_function_decl): Return error_mark_node if
            substituting into the formal parameter list failed.
            (tsubst_decl) <case PARM_DECL>: Return error_mark_node
            upon TREE_TYPE substitution failure, when in a SFINAE
            context.  Return error_mark_node upon DECL_CHAIN substitution
            failure.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/alias-decl-80.C: New test.

    Reviewed-by: Jason Merrill <ja...@redhat.com>
    (cherry picked from commit 51e93aadc94940e2da854cf1321a7ab1aebf8d1a)

Reply via email to