instantiate-member-pointers.cpp revision 949bf69136e07fb7968d84bc21d9272ff343ffdb
1// RUN: clang-cc -fsyntax-only -verify %s 2 3struct Y { 4 int x; 5}; 6 7template<typename T> 8struct X1 { 9 int f(T* ptr, int T::*pm) { // expected-error{{member pointer}} 10 return ptr->*pm; 11 } 12}; 13 14template struct X1<Y>; 15template struct X1<int>; // expected-note{{instantiation}} 16 17template<typename T, typename Class> 18struct X2 { 19 T f(Class &obj, T Class::*pm) { // expected-error{{to a reference}} \ 20 // expected-error{{member pointer to void}} 21 return obj.*pm; 22 } 23}; 24 25template struct X2<int, Y>; 26template struct X2<int&, Y>; // expected-note{{instantiation}} 27template struct X2<const void, Y>; // expected-note{{instantiation}} 28