xref: /llvm-project/clang/test/Modules/method_pool.m (revision 6ba4afb4d6f2f8f293ad704a37de4139c5c8c0f0)
1// RUN: rm -rf %t
2// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -verify
3
4
5@import MethodPoolA;
6
7@interface D
8- (void)method5:(D*)obj;
9@end
10
11// expected-note@Inputs/MethodPoolA.h:7{{using}}
12// expected-note@Inputs/MethodPoolB.h:12{{also found}}
13
14void testMethod1(id object) {
15  [object method1];
16}
17
18void testMethod2(id object) {
19  [object method2:1];
20}
21
22void testMethod4(id object) {
23  [object method4]; // expected-warning{{instance method '-method4' not found (return type defaults to 'id')}}
24}
25
26void testMethod5(id object, D* d) {
27  [object method5:d];
28}
29
30@import MethodPoolB;
31// expected-error@MethodPoolB.h:* {{'B' has different definitions in different modules; first difference is definition in module 'MethodPoolB' found no super class}}
32// expected-note@MethodPoolA.h:* {{but in 'MethodPoolA' found super class with type 'A'}}
33
34void testMethod1Again(id object) {
35  [object method1];
36}
37
38void testMethod2Again(id object) {
39  [object method2:1]; // expected-warning{{multiple methods named 'method2:' found}}
40}
41
42void testMethod3(id object) {
43  [object method3]; // expected-warning{{instance method '-method3' not found (return type defaults to 'id')}}
44}
45
46@import MethodPoolB.Sub;
47
48void testMethod3Again(id object) {
49  char *str = [object method3]; // okay: only found in MethodPoolB.Sub
50}
51
52void testMethod6(id object) {
53  [object method6];
54}
55
56@import MethodPoolA.Sub;
57
58void testMethod3AgainAgain(id object) {
59  [object method3]; // expected-warning{{multiple methods named 'method3' found}}
60  // expected-note@Inputs/MethodPoolBSub.h:2{{using}}
61  // expected-note@Inputs/MethodPoolASub.h:2{{also found}}
62}
63
64void testMethod4Again(id object) {
65  [object method4];
66}
67
68void testMethod5Again(id object, D* d) {
69  [object method5:d];
70}
71