Richard Smith | 2592327 | 2017-08-25 01:47:55 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++2a %s -verify |
| 2 | |
| 3 | struct X { |
Jacob Bandes-Storch | bb93578 | 2017-12-31 18:27:29 +0000 | [diff] [blame] | 4 | void ref() & {} // expected-note{{'ref' declared here}} |
Richard Smith | 2592327 | 2017-08-25 01:47:55 +0000 | [diff] [blame] | 5 | void cref() const& {} |
| 6 | }; |
| 7 | |
| 8 | void test() { |
Jacob Bandes-Storch | bb93578 | 2017-12-31 18:27:29 +0000 | [diff] [blame] | 9 | X{}.ref(); // expected-error{{'this' argument to member function 'ref' is an rvalue, but function has non-const lvalue ref-qualifier}} |
Richard Smith | 2592327 | 2017-08-25 01:47:55 +0000 | [diff] [blame] | 10 | X{}.cref(); // expected-no-error |
| 11 | |
Richard Smith | cae37ca | 2017-08-25 01:55:50 +0000 | [diff] [blame] | 12 | (X{}.*&X::ref)(); // expected-error-re{{pointer-to-member function type 'void (X::*)() {{.*}}&' can only be called on an lvalue}} |
Richard Smith | 2592327 | 2017-08-25 01:47:55 +0000 | [diff] [blame] | 13 | (X{}.*&X::cref)(); // expected-no-error |
| 14 | } |