gcc/testsuite/g++.dg/cpp23/explicit-obj-by-value4.C
raw| 1 | // P0847R7 |
| 2 | // { dg-do compile { target c++23 } } |
| 3 | |
| 4 | // diagnosis of ill-formed calls to by-value xobj member functions |
| 5 | // due to an absence of valid conversion functions |
| 6 | |
| 7 | struct NotFromS {}; |
| 8 | |
| 9 | struct S { |
| 10 | void f(this int) {} |
| 11 | void g(this NotFromS) {} |
| 12 | }; |
| 13 | |
| 14 | void test() |
| 15 | { |
| 16 | S s{}; |
| 17 | s.f(); // { dg-error {cannot convert 'S' to 'int'} } |
| 18 | s.g(); // { dg-error {cannot convert 'S' to 'NotFromS'} } |
| 19 | } |
| 20 |