c++: ignore explicit dguides during NTTP CTAD [PR101883]

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.
This commit is contained in:
Patrick Palka 2021-08-18 08:37:42 -04:00
parent 88ef1a14bb
commit a6b3db3e86
2 changed files with 10 additions and 1 deletions

View 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;
}

View File

@ -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" }