aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2023-03-22 11:12:57 -0400
committerJason Merrill <jason@redhat.com>2023-03-22 15:29:59 -0400
commit5a1717fbdfd1242a5beb3ac8300766a3534d3f88 (patch)
treefc4cba2400a29a036578e930925d1ced3aed4bd5
parent3e791f45ded89626bc1f9f8013728f6e035801b2 (diff)
downloadgcc-5a1717fbdfd1242a5beb3ac8300766a3534d3f88.zip
gcc-5a1717fbdfd1242a5beb3ac8300766a3534d3f88.tar.gz
gcc-5a1717fbdfd1242a5beb3ac8300766a3534d3f88.tar.bz2
c++: array bound partial ordering [PR108390]
fold_convert doesn't work with a dependent argument, and problematically differed from the corresponding fold+build_nop further down in the function. So change it to match. PR c++/108390 gcc/cp/ChangeLog: * pt.cc (unify): Use fold of build_nop instead of fold_convert. gcc/testsuite/ChangeLog: * g++.dg/template/partial-order3.C: New test.
-rw-r--r--gcc/cp/pt.cc8
-rw-r--r--gcc/testsuite/g++.dg/template/partial-order3.C6
2 files changed, 11 insertions, 3 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 056b8c7..90bcaa7 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -24635,8 +24635,9 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
if ((strict & UNIFY_ALLOW_INTEGER)
&& TREE_TYPE (targ) && TREE_TYPE (arg)
&& CP_INTEGRAL_TYPE_P (TREE_TYPE (targ)))
- /* We're deducing from an array bound, the type doesn't matter. */
- arg = fold_convert (TREE_TYPE (targ), arg);
+ /* We're deducing from an array bound, the type doesn't matter.
+ This conversion should match the one below. */
+ arg = fold (build_nop (TREE_TYPE (targ), arg));
int x = !cp_tree_equal (targ, arg);
if (x)
unify_inconsistency (explain_p, parm, targ, arg);
@@ -24684,7 +24685,8 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
&& CP_INTEGRAL_TYPE_P (tparm))
/* Convert the ARG to the type of PARM; the deduced non-type
template argument must exactly match the types of the
- corresponding parameter. */
+ corresponding parameter. This conversion should match the
+ one above. */
arg = fold (build_nop (tparm, arg));
else if (uses_template_parms (tparm))
{
diff --git a/gcc/testsuite/g++.dg/template/partial-order3.C b/gcc/testsuite/g++.dg/template/partial-order3.C
new file mode 100644
index 0000000..1545053
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/partial-order3.C
@@ -0,0 +1,6 @@
+// PR c++/108390
+// { dg-do compile { target c++11 } }
+
+template<class T, T t> long f(int(*)[t], T(*)[t]);
+template<class T, int i> int f(int(*)[i], T(*)[i]) = delete;
+int n = f<int, 2>(0, 0);