1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify %s 2*67e74705SXin Li 3*67e74705SXin Li// Test template instantiation of Objective-C message sends. 4*67e74705SXin Li 5*67e74705SXin Li@interface ClassMethods 6*67e74705SXin Li+ (ClassMethods *)method1:(void*)ptr; 7*67e74705SXin Li@end 8*67e74705SXin Li 9*67e74705SXin Litemplate<typename T> 10*67e74705SXin Listruct identity { 11*67e74705SXin Li typedef T type; 12*67e74705SXin Li}; 13*67e74705SXin Li 14*67e74705SXin Litemplate<typename R, typename T, typename Arg1> 15*67e74705SXin Livoid test_class_method(Arg1 arg1) { 16*67e74705SXin Li R *result1 = [T method1:arg1]; 17*67e74705SXin Li R *result2 = [typename identity<T>::type method1:arg1]; 18*67e74705SXin Li R *result3 = [ClassMethods method1:arg1]; // expected-error{{cannot initialize a variable of type 'ClassMethods2 *' with an rvalue of type 'ClassMethods *'}} 19*67e74705SXin Li} 20*67e74705SXin Li 21*67e74705SXin Litemplate void test_class_method<ClassMethods, ClassMethods>(void*); 22*67e74705SXin Litemplate void test_class_method<ClassMethods, ClassMethods>(int*); 23*67e74705SXin Li 24*67e74705SXin Li@interface ClassMethods2 25*67e74705SXin Li+ (ClassMethods2 *)method1:(int*)ptr; 26*67e74705SXin Li@end 27*67e74705SXin Li 28*67e74705SXin Litemplate void test_class_method<ClassMethods2, ClassMethods2>(int*); // expected-note{{in instantiation of}} 29*67e74705SXin Li 30*67e74705SXin Li 31*67e74705SXin Li@interface InstanceMethods 32*67e74705SXin Li- (InstanceMethods *)method1:(void*)ptr; 33*67e74705SXin Li@end 34*67e74705SXin Li 35*67e74705SXin Litemplate<typename R, typename T, typename Arg1> 36*67e74705SXin Livoid test_instance_method(Arg1 arg1) { 37*67e74705SXin Li T *receiver = 0; 38*67e74705SXin Li InstanceMethods *im = 0; 39*67e74705SXin Li R *result1 = [receiver method1:arg1]; 40*67e74705SXin Li R *result2 = [im method1:arg1]; // expected-error{{cannot initialize a variable of type 'InstanceMethods2 *' with an rvalue of type 'InstanceMethods *'}} 41*67e74705SXin Li} 42*67e74705SXin Li 43*67e74705SXin Litemplate void test_instance_method<InstanceMethods, InstanceMethods>(void*); 44*67e74705SXin Litemplate void test_instance_method<InstanceMethods, InstanceMethods>(int*); 45*67e74705SXin Li 46*67e74705SXin Li@interface InstanceMethods2 47*67e74705SXin Li- (InstanceMethods2 *)method1:(void*)ptr; 48*67e74705SXin Li@end 49*67e74705SXin Li 50*67e74705SXin Litemplate void test_instance_method<InstanceMethods2, InstanceMethods2>(int*); // expected-note{{in instantiation of}} 51