| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
class A { |
| 3 |
public: |
| 4 |
int& i; |
| 5 |
|
| 6 |
A(int& i) : i(i) { } |
| 7 |
|
| 8 |
static int s; |
| 9 |
}; |
| 10 |
|
| 11 |
template<typename T> void ft(T& t) { |
| 12 |
t.*&T::i = 10; // expected-error{{cannot form a pointer-to-member to member 'i' of reference type 'int &'}} |
| 13 |
} |
| 14 |
|
| 15 |
void f() { |
| 16 |
int b; |
| 17 |
A a(b); |
| 18 |
|
| 19 |
int A::*ip = &A::s; // expected-error {{cannot initialize a variable of type 'int A::*' with an rvalue of type 'int *'}} |
| 20 |
a.*&A::s = 10; // expected-error{{right hand operand to .* has non-pointer-to-member type 'int *'}} |
| 21 |
|
| 22 |
a.*&A::i = 10; // expected-error{{cannot form a pointer-to-member to member 'i' of reference type 'int &'}} |
| 23 |
ft(a); // expected-note{{in instantiation of function template specialization 'ft<A>' requested here}} |
| 24 |
|
| 25 |
void A::*p = 0; // expected-error{{'p' declared as a member pointer to void}} |
| 26 |
} |