p6-0x.cpp 1.6 KB

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