c++: constrained surrogate call functions [PR110535]
We weren't checking constraints on pointer/reference-to-function conversion functions during overload resolution, which caused us to ICE on the first testcase and reject the second testcase. PR c++/110535 gcc/cp/ChangeLog: * call.cc (add_conv_candidate): Check constraints. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-surrogate1.C: New test. * g++.dg/cpp2a/concepts-surrogate2.C: New test.
This commit is contained in:
parent
054e93b875
commit
1e0f37df1b
3 changed files with 34 additions and 0 deletions
|
@ -2588,6 +2588,14 @@ add_conv_candidate (struct z_candidate **candidates, tree fn, tree obj,
|
|||
if (*candidates && (*candidates)->fn == totype)
|
||||
return NULL;
|
||||
|
||||
if (!constraints_satisfied_p (fn))
|
||||
{
|
||||
reason = constraint_failure ();
|
||||
viable = 0;
|
||||
return add_candidate (candidates, fn, obj, arglist, len, convs,
|
||||
access_path, conversion_path, viable, reason, flags);
|
||||
}
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
{
|
||||
tree arg, argtype, convert_type = NULL_TREE;
|
||||
|
|
12
gcc/testsuite/g++.dg/cpp2a/concepts-surrogate1.C
Normal file
12
gcc/testsuite/g++.dg/cpp2a/concepts-surrogate1.C
Normal file
|
@ -0,0 +1,12 @@
|
|||
// PR c++/110535
|
||||
// { dg-do compile { target c++20 } }
|
||||
|
||||
using F = int(int);
|
||||
|
||||
template<bool B>
|
||||
struct A {
|
||||
operator F*() requires B;
|
||||
};
|
||||
|
||||
int i = A<true>{}(0); // OK
|
||||
int j = A<false>{}(0); // { dg-error "no match" }
|
14
gcc/testsuite/g++.dg/cpp2a/concepts-surrogate2.C
Normal file
14
gcc/testsuite/g++.dg/cpp2a/concepts-surrogate2.C
Normal file
|
@ -0,0 +1,14 @@
|
|||
// PR c++/110535
|
||||
// { dg-do compile { target c++20 } }
|
||||
|
||||
using F = int(int);
|
||||
using G = long(int);
|
||||
|
||||
template<bool B>
|
||||
struct A {
|
||||
operator F&() requires B;
|
||||
operator G&() requires (!B);
|
||||
};
|
||||
|
||||
int i = A<true>{}(0); // { dg-bogus "ambiguous" }
|
||||
int j = A<false>{}(0); // { dg-bogus "ambiguous" }
|
Loading…
Add table
Reference in a new issue