From: Jason Merrill Date: Fri, 9 May 2025 15:05:13 +0000 (-0400) Subject: c++: CWG2369 workaround and ... [PR120185] X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=21842fe301caa5dbc69a69033cdc17bb29b8c399;p=thirdparty%2Fgcc.git c++: CWG2369 workaround and ... [PR120185] My r16-479 adjustment to the PR99599 workaround broke on a class with a varargs constructor. It also occurred to me that we don't need to do non-dep conversion checking in two phases when concepts aren't supported. PR c++/99599 PR c++/120185 gcc/cp/ChangeLog: * class.cc (type_has_converting_constructor): Handle null parm. * pt.cc (fn_type_unification): Skip early non-dep checking if no concepts. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-nondep6.C: New test. --- diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc index 370bfa35f9e..2764bb52ddd 100644 --- a/gcc/cp/class.cc +++ b/gcc/cp/class.cc @@ -5744,6 +5744,9 @@ type_has_converting_constructor (tree t) { tree fn = *iter; tree parm = FUNCTION_FIRST_USER_PARMTYPE (fn); + if (parm == NULL_TREE) + /* Varargs. */ + return true; if (parm == void_list_node || !sufficient_parms_p (TREE_CHAIN (parm))) /* Can't accept a single argument, so won't be considered for diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 0694c28cde3..09f74a2814b 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -23254,7 +23254,7 @@ fn_type_unification (tree fn, conversions that we know are not going to induce template instantiation (PR99599). */ if (strict == DEDUCE_CALL - && incomplete + && incomplete && flag_concepts && check_non_deducible_conversions (parms, args, nargs, fn, strict, flags, convs, explain_p, /*noninst_only_p=*/true)) diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-nondep6.C b/gcc/testsuite/g++.dg/cpp2a/concepts-nondep6.C new file mode 100644 index 00000000000..7adf6ecfb86 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-nondep6.C @@ -0,0 +1,12 @@ +// PR c++/120185 + +struct A { + A(...); +}; + +template void f(A, T) { } + +int main() +{ + f(42, 24); +}