gcc/testsuite/g++.dg/cpp23/explicit-obj-lambda14.C
raw| 1 | // PR c++/113640 |
| 2 | // { dg-do run { target c++23 } } |
| 3 | |
| 4 | static int total; |
| 5 | |
| 6 | struct A { |
| 7 | A f(this auto self, int n) { |
| 8 | total += n; |
| 9 | return self; |
| 10 | } |
| 11 | }; |
| 12 | |
| 13 | int main() { |
| 14 | A a; |
| 15 | a.f(1).f(42).f(100); |
| 16 | if (total != 143) |
| 17 | __builtin_abort(); |
| 18 | |
| 19 | auto l = [](this auto self, int n) { |
| 20 | total += n; |
| 21 | return self; |
| 22 | }; |
| 23 | total = 0; |
| 24 | l(1)(42)(100); |
| 25 | if (total != 143) |
| 26 | __builtin_abort(); |
| 27 | } |