[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / clang / test / SemaObjC / method-conflict-1.m
blob654cd0166fb50fd7f0e4ceacfbe0c3c1a89ccb5c
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2 // expected-no-diagnostics
4 // This test case tests the default behavior.
6 // rdar://7933061
8 @interface NSObject @end
10 @interface NSArray : NSObject @end
12 @interface MyClass : NSObject {
14 - (void)myMethod:(NSArray *)object;
15 - (void)myMethod1:(NSObject *)object; // broken-note {{previous definition is here}}
16 @end
18 @implementation MyClass
19 - (void)myMethod:(NSObject *)object {
21 - (void)myMethod1:(NSArray *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'NSObject *' vs 'NSArray *'}}
23 @end
26 @protocol MyProtocol @end
28 @interface MyOtherClass : NSObject <MyProtocol> {
30 - (void)myMethod:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
31 - (void)myMethod1:(id <MyProtocol>)object; // broken-note {{previous definition is here}}
32 @end
34 @implementation MyOtherClass
35 - (void)myMethod:(MyClass *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod:': 'id<MyProtocol>' vs 'MyClass *'}}
37 - (void)myMethod1:(MyClass<MyProtocol> *)object { // broken-warning {{conflicting parameter types in implementation of 'myMethod1:': 'id<MyProtocol>' vs 'MyClass<MyProtocol> *'}}
39 @end
43 @interface A @end
44 @interface B : A @end
46 @interface Test1 {}
47 - (void) test1:(A*) object; // broken-note {{previous definition is here}} 
48 - (void) test2:(B*) object;
49 @end
51 @implementation Test1
52 - (void) test1:(B*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}}
53 - (void) test2:(A*) object {}
54 @end
56 // rdar://problem/8597621 wants id -> A* to be an exception
57 @interface Test2 {}
58 - (void) test1:(id) object; // broken-note {{previous definition is here}} 
59 - (void) test2:(A*) object;
60 @end
61 @implementation Test2
62 - (void) test1:(A*) object {} // broken-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}}
63 - (void) test2:(id) object {}
64 @end
66 @interface Test3 {}
67 - (A*) test1;
68 - (B*) test2; // broken-note {{previous definition is here}} 
69 @end
71 @implementation Test3
72 - (B*) test1 { return 0; }
73 - (A*) test2 { return 0; } // broken-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}}
74 @end
76 // The particular case of overriding with an id return is white-listed.
77 @interface Test4 {}
78 - (id) test1;
79 - (A*) test2;
80 @end
81 @implementation Test4
82 - (A*) test1 { return 0; } // id -> A* is rdar://problem/8596987
83 - (id) test2 { return 0; }
84 @end