summaryrefslogtreecommitdiff
path: root/test/SemaCXX/cxx2a-pointer-to-const-ref-member.cpp
blob: 7c709d905f78830f0588a888212585be736ba53e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// RUN: %clang_cc1 -std=c++2a %s -verify

struct X {
  void ref() & {} // expected-note{{'ref' declared here}}
  void cref() const& {}
  void cvref() const volatile & {} // expected-note{{'cvref' declared here}}
};

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{}.cvref(); // expected-error{{'this' argument to member function 'cvref' is an rvalue, but function has non-const lvalue ref-qualifier}}

  (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
  (X{}.*&X::cvref)(); // expected-error-re{{pointer-to-member function type 'void (X::*)() {{.*}}&' can only be called on an lvalue}}
}