]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: more non-type template parms [PR116223]
authorJason Merrill <jason@redhat.com>
Mon, 5 Aug 2024 17:20:17 +0000 (13:20 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 6 Aug 2024 17:04:23 +0000 (13:04 -0400)
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.

gcc/cp/pt.cc

index cf65b347f6cab00525f5cc12eceb563a0b8d9d5d..677ed7d128966efcfd8f1d1f3254952f9fb5d17e 100644 (file)
@@ -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