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: upstream/12.2.0~5707 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a6b3db3e8625a3cba1240f0b5e1a29bd6c68b8ca;p=platform%2Fupstream%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. --- diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 484723b..0c14966 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 0000000..c83e407 --- /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" }