1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 // Test template instantiation of Objective-C message sends.
5 @interface ClassMethods
6 + (ClassMethods *)method1:(void*)ptr;
14 template<typename R, typename T, typename Arg1>
15 void 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 *'}}
21 template void test_class_method<ClassMethods, ClassMethods>(void*);
22 template void test_class_method<ClassMethods, ClassMethods>(int*);
24 @interface ClassMethods2
25 + (ClassMethods2 *)method1:(int*)ptr;
28 template void test_class_method<ClassMethods2, ClassMethods2>(int*); // expected-note{{in instantiation of}}
31 @interface InstanceMethods
32 - (InstanceMethods *)method1:(void*)ptr;
35 template<typename R, typename T, typename Arg1>
36 void test_instance_method(Arg1 arg1) {
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 *'}}
43 template void test_instance_method<InstanceMethods, InstanceMethods>(void*);
44 template void test_instance_method<InstanceMethods, InstanceMethods>(int*);
46 @interface InstanceMethods2
47 - (InstanceMethods2 *)method1:(void*)ptr;
50 template void test_instance_method<InstanceMethods2, InstanceMethods2>(int*); // expected-note{{in instantiation of}}