blob: 7c709d905f78830f0588a888212585be736ba53e [file] [log] [blame]
Richard Smith25923272017-08-25 01:47:55 +00001// RUN: %clang_cc1 -std=c++2a %s -verify
2
3struct X {
Jacob Bandes-Storchbb935782017-12-31 18:27:29 +00004 void ref() & {} // expected-note{{'ref' declared here}}
Richard Smith25923272017-08-25 01:47:55 +00005 void cref() const& {}
Nicolas Lesser1ad0e9f2018-07-13 16:27:45 +00006 void cvref() const volatile & {} // expected-note{{'cvref' declared here}}
Richard Smith25923272017-08-25 01:47:55 +00007};
8
9void test() {
Jacob Bandes-Storchbb935782017-12-31 18:27:29 +000010 X{}.ref(); // expected-error{{'this' argument to member function 'ref' is an rvalue, but function has non-const lvalue ref-qualifier}}
Richard Smith25923272017-08-25 01:47:55 +000011 X{}.cref(); // expected-no-error
Nicolas Lesser1ad0e9f2018-07-13 16:27:45 +000012 X{}.cvref(); // expected-error{{'this' argument to member function 'cvref' is an rvalue, but function has non-const lvalue ref-qualifier}}
Richard Smith25923272017-08-25 01:47:55 +000013
Richard Smithcae37ca2017-08-25 01:55:50 +000014 (X{}.*&X::ref)(); // expected-error-re{{pointer-to-member function type 'void (X::*)() {{.*}}&' can only be called on an lvalue}}
Richard Smith25923272017-08-25 01:47:55 +000015 (X{}.*&X::cref)(); // expected-no-error
Nicolas Lesser1ad0e9f2018-07-13 16:27:45 +000016 (X{}.*&X::cvref)(); // expected-error-re{{pointer-to-member function type 'void (X::*)() {{.*}}&' can only be called on an lvalue}}
Richard Smith25923272017-08-25 01:47:55 +000017}