1 // RUN: %clang_cc1 -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s 2 // RUN: %clang_cc1 -x objective-c++ -Wmethod-signatures -fsyntax-only -verify -Wno-objc-root-class %s 3 4 @interface A @end 5 @interface B : A @end 6 7 @interface Test1 {} 8 - (void) test1:(A*) object; // expected-note {{previous definition is here}} 9 - (void) test2:(B*) object; 10 @end 11 12 @implementation Test1 13 - (void) test1:(B*) object {} // expected-warning {{conflicting parameter types in implementation of 'test1:': 'A *' vs 'B *'}} 14 - (void) test2:(A*) object {} 15 @end 16 17 @interface Test2 {} 18 - (void) test1:(id) object; // expected-note {{previous definition is here}} 19 - (void) test2:(A*) object; 20 @end 21 22 @implementation Test2 23 - (void) test1:(A*) object {} // expected-warning {{conflicting parameter types in implementation of 'test1:': 'id' vs 'A *'}} 24 - (void) test2:(id) object {} 25 @end 26 27 @interface Test3 {} 28 - (A*) test1; 29 - (B*) test2; // expected-note {{previous definition is here}} 30 @end 31 32 @implementation Test3 33 - (B*) test1 { return 0; } 34 - (A*) test2 { return 0; } // expected-warning {{conflicting return type in implementation of 'test2': 'B *' vs 'A *'}} 35 @end 36 37 // The particular case of overriding with an id return is white-listed. 38 @interface Test4 {} 39 - (id) test1; 40 - (A*) test2; 41 @end 42 @implementation Test4 43 - (A*) test1 { return 0; } // id -> A* is rdar://problem/8596987 44 - (id) test2 { return 0; } 45 @end 46 47 // rdar://12522752 48 typedef int int32_t; 49 typedef long long int64_t; 50 51 @interface NSObject @end 52 53 @protocol CKMessage 54 @property (nonatomic,readonly,assign) int64_t sequenceNumber; // expected-note {{previous definition is here}} 55 @end 56 57 @protocol CKMessage; 58 59 @interface CKIMMessage : NSObject<CKMessage> 60 @end 61 62 @implementation CKIMMessage 63 - (int32_t)sequenceNumber { // expected-warning {{conflicting return type in implementation of 'sequenceNumber': 'int64_t' (aka 'long long') vs 'int32_t' (aka 'int')}} 64 return 0; 65 } 66 @end 67 68 // rdar://14650159 69 // Tests that property inherited indirectly from a nested protocol 70 // is seen by the method implementation type matching logic before 71 // method in super class is seen. This fixes the warning coming 72 // out of that method mismatch. 73 @interface NSObject (NSDict) 74 - (void)setValue:(id)value; 75 - (id)value; 76 @end 77 78 @protocol ProtocolWithValue 79 @property (nonatomic) unsigned value; 80 @end 81 82 @protocol InterveningProtocol <ProtocolWithValue> 83 @end 84 85 @interface UsesProtocolWithValue : NSObject <ProtocolWithValue> 86 @end 87 88 @implementation UsesProtocolWithValue 89 @synthesize value=_value; 90 - (unsigned) value 91 { 92 return _value; 93 } 94 - (void) setValue:(unsigned)value 95 { 96 _value = value; 97 } 98 @end 99 100 101 @interface UsesInterveningProtocol : NSObject <InterveningProtocol> 102 @end 103 104 @implementation UsesInterveningProtocol 105 106 @synthesize value=_value; 107 - (unsigned) value 108 { 109 return _value; 110 } 111 - (void) setValue:(unsigned)value 112 { 113 _value = value; 114 } 115 @end 116