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

Jason Merrill jason@redhat.com
Mon Aug 16 20:06:06 GMT 2021


On 8/16/21 3:06 PM, Patrick Palka wrote:
> 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.
> 
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
> trunk/11?

OK.

> 	PR c++/101883
> 
> gcc/cp/ChangeLog:
> 
> 	* pt.c (convert_template_argument): Pass LOOKUP_IMPLICIT to
> 	convert_template_argument.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/cpp2a/nontype-class49.C: New test.
> ---
>   gcc/cp/pt.c                                  | 3 ++-
>   gcc/testsuite/g++.dg/cpp2a/nontype-class49.C | 8 ++++++++
>   2 files changed, 10 insertions(+), 1 deletion(-)
>   create mode 100644 gcc/testsuite/g++.dg/cpp2a/nontype-class49.C
> 
> diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
> index 0870ccdc9f6..5ac89901e22 100644
> --- a/gcc/cp/pt.c
> +++ b/gcc/cp/pt.c
> @@ -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
> index 00000000000..c83e4075ed0
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp2a/nontype-class49.C
> @@ -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" }
> 



More information about the Gcc-patches mailing list