aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/pt.cc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2024-08-05 13:20:17 -0400
committerJason Merrill <jason@redhat.com>2024-08-06 13:04:23 -0400
commitb2a8ee0e5d8cfa92bafd0db4b03626b26ac21948 (patch)
tree0787904e752335118db3fb2a9c9781c9304e06b6 /gcc/cp/pt.cc
parent4add6cd341a779e980e41ed6fb49175fca37496e (diff)
downloadgcc-b2a8ee0e5d8cfa92bafd0db4b03626b26ac21948.zip
gcc-b2a8ee0e5d8cfa92bafd0db4b03626b26ac21948.tar.gz
gcc-b2a8ee0e5d8cfa92bafd0db4b03626b26ac21948.tar.bz2
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.
Diffstat (limited to 'gcc/cp/pt.cc')
-rw-r--r--gcc/cp/pt.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index cf65b34..677ed7d 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