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& {} |
Nicolas Lesser | 1ad0e9f | 2018-07-13 16:27:45 +0000 | [diff] [blame] | 6 | void cvref() const volatile & {} // expected-note{{'cvref' declared here}} |
Richard Smith | 2592327 | 2017-08-25 01:47:55 +0000 | [diff] [blame] | 7 | }; |
| 8 | |
| 9 | void test() { |
Jacob Bandes-Storch | bb93578 | 2017-12-31 18:27:29 +0000 | [diff] [blame] | 10 | 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] | 11 | X{}.cref(); // expected-no-error |
Nicolas Lesser | 1ad0e9f | 2018-07-13 16:27:45 +0000 | [diff] [blame] | 12 | X{}.cvref(); // expected-error{{'this' argument to member function 'cvref' is an rvalue, but function has non-const lvalue ref-qualifier}} |
Richard Smith | 2592327 | 2017-08-25 01:47:55 +0000 | [diff] [blame] | 13 | |
Richard Smith | cae37ca | 2017-08-25 01:55:50 +0000 | [diff] [blame] | 14 | (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] | 15 | (X{}.*&X::cref)(); // expected-no-error |
Nicolas Lesser | 1ad0e9f | 2018-07-13 16:27:45 +0000 | [diff] [blame] | 16 | (X{}.*&X::cvref)(); // 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] | 17 | } |