(Re-submission of D39937 with fixed tests.) Adjust wording for const-qualification mismatch to be a little more clear. Also add another diagnostic for a ref qualifier mismatch, which previously produced a useless error (this error path is simply very old; see rL119336): Before: error: cannot initialize object parameter of type 'X0' with an expression of type 'X0' After: error: 'this' argument to member function 'rvalue' is an lvalue, but function has rvalue ref-qualifier Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: lebedev.ri, cfe-commits Differential Revision: https://reviews.llvm.org/D41646 llvm-svn: 321609
15 lines
502 B
C++
15 lines
502 B
C++
// RUN: %clang_cc1 -std=c++2a %s -verify
|
|
|
|
struct X {
|
|
void ref() & {} // expected-note{{'ref' declared here}}
|
|
void cref() const& {}
|
|
};
|
|
|
|
void test() {
|
|
X{}.ref(); // expected-error{{'this' argument to member function 'ref' is an rvalue, but function has non-const lvalue ref-qualifier}}
|
|
X{}.cref(); // expected-no-error
|
|
|
|
(X{}.*&X::ref)(); // expected-error-re{{pointer-to-member function type 'void (X::*)() {{.*}}&' can only be called on an lvalue}}
|
|
(X{}.*&X::cref)(); // expected-no-error
|
|
}
|