From: Patrick Palka Date: Wed, 18 Aug 2021 12:37:42 +0000 (-0400) Subject: c++: ignore explicit dguides during NTTP CTAD [PR101883] X-Git-Tag: releases/gcc-11.3.0~815 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=52dd840c5eba25ef54dee3f1c78f371032a7c051;p=thirdparty%2Fgcc.git 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. (cherry picked from commit a6b3db3e8625a3cba1240f0b5e1a29bd6c68b8ca) --- diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 45f39ab7fff6..077097d91753 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8514,7 +8514,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 000000000000..c83e4075ed07 --- /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 struct C { constexpr C(int) { } }; +explicit C(int) -> C; + +template struct X { }; +X<1> x; // { dg-error "deduction|no match" }