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