| 1 |
// In a .* expression whose object expression is an rvalue, the program is |
| 2 |
// ill-formed if the second operand is a pointer to member function with |
| 3 |
// ref-qualifier &. In a .* expression whose object expression is an |
| 4 |
// lvalue, the program is ill-formed if the second operand is a pointer to |
| 5 |
// member function with ref-qualifier &&. |
| 6 |
|
| 7 |
// { dg-require-effective-target c++11 } |
| 8 |
|
| 9 |
struct A { |
| 10 |
void f() &; |
| 11 |
void g() &&; |
| 12 |
void h(); |
| 13 |
}; |
| 14 |
|
| 15 |
void one() |
| 16 |
{ |
| 17 |
A a; |
| 18 |
|
| 19 |
void (A::*p)() & = &A::f; |
| 20 |
(a.*p)(); |
| 21 |
(A().*p)(); // { dg-error "" } |
| 22 |
|
| 23 |
p = &A::g; // { dg-error "" } |
| 24 |
p = &A::h; // { dg-error "" } |
| 25 |
|
| 26 |
void (A::*p2)() && = &A::g; |
| 27 |
(A().*p2)(); |
| 28 |
(a.*p2)(); // { dg-error "" } |
| 29 |
p2 = &A::f; // { dg-error "" } |
| 30 |
p2 = &A::h; // { dg-error "" } |
| 31 |
|
| 32 |
void (A::*p3)() = &A::h; |
| 33 |
(a.*p3)(); |
| 34 |
(A().*p3)(); |
| 35 |
p3 = &A::f; // { dg-error "" } |
| 36 |
p3 = &A::g; // { dg-error "" } |
| 37 |
} |
| 38 |
|
| 39 |
template <class T> |
| 40 |
struct B { |
| 41 |
void f() &; |
| 42 |
void g() &&; |
| 43 |
void h(); |
| 44 |
}; |
| 45 |
|
| 46 |
template <class T> |
| 47 |
void two() |
| 48 |
{ |
| 49 |
B<T> a; |
| 50 |
|
| 51 |
void (B<T>::*p)() & = &B<T>::f; |
| 52 |
(a.*p)(); |
| 53 |
(B<T>().*p)(); // { dg-error "" } |
| 54 |
|
| 55 |
p = &B<T>::g; // { dg-error "" } |
| 56 |
p = &B<T>::h; // { dg-error "" } |
| 57 |
|
| 58 |
void (B<T>::*p2)() && = &B<T>::g; |
| 59 |
(B<T>().*p2)(); |
| 60 |
(a.*p2)(); // { dg-error "" } |
| 61 |
p2 = &B<T>::f; // { dg-error "" } |
| 62 |
p2 = &B<T>::h; // { dg-error "" } |
| 63 |
|
| 64 |
void (B<T>::*p3)() = &B<T>::h; |
| 65 |
(a.*p3)(); |
| 66 |
(B<T>().*p3)(); |
| 67 |
p3 = &B<T>::f; // { dg-error "" } |
| 68 |
p3 = &B<T>::g; // { dg-error "" } |
| 69 |
} |
| 70 |
|
| 71 |
int main() |
| 72 |
{ |
| 73 |
one(); |
| 74 |
two<int>(); |
| 75 |
} |