c++: ignore explicit dguides during NTTP CTAD [PR101883]
authorPatrick Palka <ppalka@redhat.com>
Wed, 18 Aug 2021 12:37:42 +0000 (08:37 -0400)
committerPatrick Palka <ppalka@redhat.com>
Wed, 18 Aug 2021 12:37:42 +0000 (08:37 -0400)
Since (template) argument passing is a copy-initialization context,
we mustn't consider explicit deduction guides when deducing a CTAD
placeholder type of an NTTP.

PR c++/101883

gcc/cp/ChangeLog:

* pt.c (convert_template_argument): Pass LOOKUP_IMPLICIT to
do_auto_deduction.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/nontype-class49.C: New test.

gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp2a/nontype-class49.C [new file with mode: 0644]

index 484723b..0c14966 100644 (file)
@@ -8486,7 +8486,8 @@ convert_template_argument (tree parm,
           can happen in the context of -fnew-ttp-matching.  */;
       else if (tree a = type_uses_auto (t))
        {
-         t = do_auto_deduction (t, arg, a, complain, adc_unify, args);
+         t = do_auto_deduction (t, arg, a, complain, adc_unify, args,
+                                LOOKUP_IMPLICIT);
          if (t == error_mark_node)
            return error_mark_node;
        }
diff --git a/gcc/testsuite/g++.dg/cpp2a/nontype-class49.C b/gcc/testsuite/g++.dg/cpp2a/nontype-class49.C
new file mode 100644 (file)
index 0000000..c83e407
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/101883
+// { dg-do compile { target c++20 } }
+
+template<class T> struct C { constexpr C(int) { } };
+explicit C(int) -> C<int>;
+
+template<C c> struct X { };
+X<1> x; // { dg-error "deduction|no match" }