File: p6-0x.cpp

package info (click to toggle)
llvm-toolchain-6.0 1%3A6.0.1-10
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 598,080 kB
  • sloc: cpp: 3,046,253; ansic: 595,057; asm: 271,965; python: 128,926; objc: 106,554; sh: 21,906; lisp: 10,191; pascal: 6,094; ml: 5,544; perl: 5,265; makefile: 2,227; cs: 2,027; xml: 686; php: 212; csh: 117
file content (34 lines) | stat: -rw-r--r-- 1,605 bytes parent folder | download | duplicates (37)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s

struct X { };

template<typename T> T& lvalue();
template<typename T> T&& xvalue();
template<typename T> T prvalue();

// In a .* expression whose object expression is an rvalue, the
// program is ill-formed if the second operand is a pointer to member
// function with ref-qualifier &. In a ->* expression or in a .*
// expression whose object expression is an lvalue, the program is
// ill-formed if the second operand is a pointer to member function
// with ref-qualifier &&.
void test(X *xp, int (X::*pmf)(int), int (X::*l_pmf)(int) &, 
          int (X::*r_pmf)(int) &&) {
  // No ref-qualifier.
  (lvalue<X>().*pmf)(17);
  (xvalue<X>().*pmf)(17);
  (prvalue<X>().*pmf)(17);
  (xp->*pmf)(17);

  // Lvalue ref-qualifier.
  (lvalue<X>().*l_pmf)(17);
  (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}}
  (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}}
  (xp->*l_pmf)(17);

  // Rvalue ref-qualifier.
  (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}}
  (xvalue<X>().*r_pmf)(17);
  (prvalue<X>().*r_pmf)(17);
  (xp->*r_pmf)(17);  // expected-error-re{{pointer-to-member function type 'int (X::*)(int){{( __attribute__\(\(thiscall\)\))?}} &&' can only be called on an rvalue}}
}