Douglas Gregor | 949bf69 | 2009-06-09 22:17:39 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
Douglas Gregor | 949bf69 | 2009-06-09 22:17:39 +0000 | [diff] [blame] | 2 | struct Y { |
| 3 | int x; |
| 4 | }; |
| 5 | |
| 6 | template<typename T> |
| 7 | struct X1 { |
| 8 | int f(T* ptr, int T::*pm) { // expected-error{{member pointer}} |
| 9 | return ptr->*pm; |
| 10 | } |
| 11 | }; |
| 12 | |
| 13 | template struct X1<Y>; |
| 14 | template struct X1<int>; // expected-note{{instantiation}} |
| 15 | |
| 16 | template<typename T, typename Class> |
| 17 | struct X2 { |
| 18 | T f(Class &obj, T Class::*pm) { // expected-error{{to a reference}} \ |
| 19 | // expected-error{{member pointer to void}} |
| 20 | return obj.*pm; |
| 21 | } |
| 22 | }; |
| 23 | |
| 24 | template struct X2<int, Y>; |
| 25 | template struct X2<int&, Y>; // expected-note{{instantiation}} |
| 26 | template struct X2<const void, Y>; // expected-note{{instantiation}} |
Douglas Gregor | 231edff | 2009-11-12 17:40:13 +0000 | [diff] [blame] | 27 | |
| 28 | template<typename T, typename Class, T Class::*Ptr> |
| 29 | struct X3 { |
| 30 | X3<T, Class, Ptr> &operator=(const T& value) { |
| 31 | return *this; |
| 32 | } |
| 33 | }; |
| 34 | |
| 35 | X3<int, Y, &Y::x> x3; |