• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2 
3 struct X { };
4 
5 template<typename T> T& lvalue();
6 template<typename T> T&& xvalue();
7 template<typename T> T prvalue();
8 
9 // In a .* expression whose object expression is an rvalue, the
10 // program is ill-formed if the second operand is a pointer to member
11 // function with ref-qualifier &. In a ->* expression or in a .*
12 // expression whose object expression is an lvalue, the program is
13 // ill-formed if the second operand is a pointer to member function
14 // with ref-qualifier &&.
test(X * xp,int (X::* pmf)(int),int (X::* l_pmf)(int)&,int (X::* r_pmf)(int)&&)15 void test(X *xp, int (X::*pmf)(int), int (X::*l_pmf)(int) &,
16           int (X::*r_pmf)(int) &&) {
17   // No ref-qualifier.
18   (lvalue<X>().*pmf)(17);
19   (xvalue<X>().*pmf)(17);
20   (prvalue<X>().*pmf)(17);
21   (xp->*pmf)(17);
22 
23   // Lvalue ref-qualifier.
24   (lvalue<X>().*l_pmf)(17);
25   (xvalue<X>().*l_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &' can only be called on an lvalue}}
26   (prvalue<X>().*l_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &' can only be called on an lvalue}}
27   (xp->*l_pmf)(17);
28 
29   // Rvalue ref-qualifier.
30   (lvalue<X>().*r_pmf)(17); // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &&' can only be called on an rvalue}}
31   (xvalue<X>().*r_pmf)(17);
32   (prvalue<X>().*r_pmf)(17);
33   (xp->*r_pmf)(17);  // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &&' can only be called on an rvalue}}
34 }
35