[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / cxx2a-pointer-to-const-ref-member.cpp
blob7c709d905f78830f0588a888212585be736ba53e
1 // RUN: %clang_cc1 -std=c++2a %s -verify
3 struct X {
4 void ref() & {} // expected-note{{'ref' declared here}}
5 void cref() const& {}
6 void cvref() const volatile & {} // expected-note{{'cvref' declared here}}
7 };
9 void test() {
10 X{}.ref(); // expected-error{{'this' argument to member function 'ref' is an rvalue, but function has non-const lvalue ref-qualifier}}
11 X{}.cref(); // expected-no-error
12 X{}.cvref(); // expected-error{{'this' argument to member function 'cvref' is an rvalue, but function has non-const lvalue ref-qualifier}}
14 (X{}.*&X::ref)(); // expected-error-re{{pointer-to-member function type 'void (X::*)() {{.*}}&' can only be called on an lvalue}}
15 (X{}.*&X::cref)(); // expected-no-error
16 (X{}.*&X::cvref)(); // expected-error-re{{pointer-to-member function type 'void (X::*)() {{.*}}&' can only be called on an lvalue}}