Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

One case missed in my fix for this PR: Here we were omitting the
IMPLICIT_CONV_EXPR that expresses the conversion from int to char because
the target type was non-dependent and the argument was not type-dependent.
But we still need it if the argument is value-dependent.

        PR c++/112632

gcc/cp/ChangeLog:

        * pt.cc (convert_template_argument): Also force IMPLICIT_CONV_EXPR
        if the argument is value-dependent.

gcc/testsuite/ChangeLog:

        * g++.dg/cpp2a/concepts-conv4.C: New test.
---
 gcc/cp/pt.cc                                | 5 +++--
 gcc/testsuite/g++.dg/cpp2a/concepts-conv4.C | 9 +++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-conv4.C

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 96ead4f1b55..bd60d515653 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -8927,8 +8927,9 @@ convert_template_argument (tree parm,
          && same_type_p (TREE_TYPE (orig_arg), t))
        orig_arg = TREE_OPERAND (orig_arg, 0);
 
-      if (!type_dependent_expression_p (orig_arg)
-         && !uses_template_parms (t))
+      if (!uses_template_parms (t)
+         && !(force_conv ? uses_template_parms (orig_arg)
+              : type_dependent_expression_p (orig_arg)))
        /* We used to call digest_init here.  However, digest_init
           will report errors, which we don't want when complain
           is zero.  More importantly, digest_init will try too
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-conv4.C 
b/gcc/testsuite/g++.dg/cpp2a/concepts-conv4.C
new file mode 100644
index 00000000000..107a1bbe4d9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-conv4.C
@@ -0,0 +1,9 @@
+// PR c++/112632
+// { dg-do compile { target c++20 } }
+
+template<int N> concept A = N != 0;
+template<char C> concept B = A<C>;
+template<int N> concept C = B<N>;
+
+static_assert(A<256>);
+static_assert(!C<256>);

base-commit: 6fda31f7b3f133a31e0a7179a82fe73b081ebbc5
-- 
2.51.0

Reply via email to