51 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3// Test template instantiation of Objective-C message sends.4 5@interface ClassMethods6+ (ClassMethods *)method1:(void*)ptr;7@end8 9template<typename T>10struct identity {11 typedef T type;12};13 14template<typename R, typename T, typename Arg1>15void test_class_method(Arg1 arg1) {16 R *result1 = [T method1:arg1];17 R *result2 = [typename identity<T>::type method1:arg1];18 R *result3 = [ClassMethods method1:arg1]; // expected-error{{cannot initialize a variable of type 'ClassMethods2 *' with an rvalue of type 'ClassMethods *'}}19}20 21template void test_class_method<ClassMethods, ClassMethods>(void*);22template void test_class_method<ClassMethods, ClassMethods>(int*);23 24@interface ClassMethods225+ (ClassMethods2 *)method1:(int*)ptr;26@end27 28template void test_class_method<ClassMethods2, ClassMethods2>(int*); // expected-note{{in instantiation of}}29 30 31@interface InstanceMethods32- (InstanceMethods *)method1:(void*)ptr;33@end34 35template<typename R, typename T, typename Arg1>36void test_instance_method(Arg1 arg1) {37 T *receiver = 0;38 InstanceMethods *im = 0;39 R *result1 = [receiver method1:arg1];40 R *result2 = [im method1:arg1]; // expected-error{{cannot initialize a variable of type 'InstanceMethods2 *' with an rvalue of type 'InstanceMethods *'}}41}42 43template void test_instance_method<InstanceMethods, InstanceMethods>(void*);44template void test_instance_method<InstanceMethods, InstanceMethods>(int*);45 46@interface InstanceMethods247- (InstanceMethods2 *)method1:(void*)ptr;48@end49 50template void test_instance_method<InstanceMethods2, InstanceMethods2>(int*); // expected-note{{in instantiation of}}51