https://gcc.gnu.org/g:b2a8ee0e5d8cfa92bafd0db4b03626b26ac21948
commit r15-2761-gb2a8ee0e5d8cfa92bafd0db4b03626b26ac21948 Author: Jason Merrill <ja...@redhat.com> Date: Mon Aug 5 13:20:17 2024 -0400 c++: more non-type template parms [PR116223] Building on the last patch, deduction should probably look through all IMPLICIT_CONV_EXPR like we do other conversions. One resulting regression turned out to be due to PR94568, fixed separately. The one other regression was for a seeming mismatch between a function and its address, handled here. Before this change we treated the IMPLICIT_CONV_EXPR as dependent because the template parameter has dependent type. PR c++/116223 gcc/cp/ChangeLog: * pt.cc (deducible_expression): Strip all IMPLICIT_CONV_EXPR. (unify): Likewise. Handle resulting function/addr mismatch. Diff: --- gcc/cp/pt.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index cf65b347f6ca..677ed7d12896 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -23031,8 +23031,7 @@ deducible_expression (tree expr) /* Strip implicit conversions and implicit INDIRECT_REFs. */ while (CONVERT_EXPR_P (expr) || TREE_CODE (expr) == VIEW_CONVERT_EXPR - || (TREE_CODE (expr) == IMPLICIT_CONV_EXPR - && IMPLICIT_CONV_EXPR_FORCED (expr)) + || TREE_CODE (expr) == IMPLICIT_CONV_EXPR || REFERENCE_REF_P (expr)) expr = TREE_OPERAND (expr, 0); return (TREE_CODE (expr) == TEMPLATE_PARM_INDEX); @@ -24563,8 +24562,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, okay. VIEW_CONVERT_EXPR can appear with class NTTP, thanks to finish_id_expression_1, and are also OK. */ while (CONVERT_EXPR_P (parm) || TREE_CODE (parm) == VIEW_CONVERT_EXPR - || (TREE_CODE (parm) == IMPLICIT_CONV_EXPR - && IMPLICIT_CONV_EXPR_FORCED (parm))) + || TREE_CODE (parm) == IMPLICIT_CONV_EXPR) parm = TREE_OPERAND (parm, 0); if (arg == error_mark_node) @@ -24578,6 +24576,12 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, if (parm == any_targ_node || arg == any_targ_node) return unify_success (explain_p); + /* Stripping IMPLICIT_CONV_EXPR above can produce this mismatch + (g++.dg/abi/mangle57.C). */ + if (TREE_CODE (parm) == FUNCTION_DECL + && TREE_CODE (arg) == ADDR_EXPR) + arg = TREE_OPERAND (arg, 0); + /* If PARM uses template parameters, then we can't bail out here, even if ARG == PARM, since we won't record unifications for the template parameters. We might need them if we're trying to