| 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 permitted. |
| 38 |
@interface Test4 {} |
| 39 |
- (id) test1; |
| 40 |
- (A*) test2; |
| 41 |
@end |
| 42 |
@implementation Test4 |
| 43 |
- (A*) test1 { return 0; } |
| 44 |
- (id) test2 { return 0; } |
| 45 |
@end |
| 46 |
|
| 47 |
typedef int int32_t; |
| 48 |
typedef long long int64_t; |
| 49 |
|
| 50 |
@interface NSObject @end |
| 51 |
|
| 52 |
@protocol CKMessage |
| 53 |
@property (nonatomic,readonly,assign) int64_t sequenceNumber; // expected-note {{previous definition is here}} |
| 54 |
@end |
| 55 |
|
| 56 |
@protocol CKMessage; |
| 57 |
|
| 58 |
@interface CKIMMessage : NSObject<CKMessage> |
| 59 |
@end |
| 60 |
|
| 61 |
@implementation CKIMMessage |
| 62 |
- (int32_t)sequenceNumber { // expected-warning {{conflicting return type in implementation of 'sequenceNumber': 'int64_t' (aka 'long long') vs 'int32_t' (aka 'int')}} |
| 63 |
return 0; |
| 64 |
} |
| 65 |
@end |
| 66 |
|
| 67 |
// Tests that property inherited indirectly from a nested protocol |
| 68 |
// is seen by the method implementation type matching logic before |
| 69 |
// method in super class is seen. This fixes the warning coming |
| 70 |
// out of that method mismatch. |
| 71 |
@interface NSObject (NSDict) |
| 72 |
- (void)setValue:(id)value; |
| 73 |
- (id)value; |
| 74 |
@end |
| 75 |
|
| 76 |
@protocol ProtocolWithValue |
| 77 |
@property (nonatomic) unsigned value; |
| 78 |
@end |
| 79 |
|
| 80 |
@protocol InterveningProtocol <ProtocolWithValue> |
| 81 |
@end |
| 82 |
|
| 83 |
@interface UsesProtocolWithValue : NSObject <ProtocolWithValue> |
| 84 |
@end |
| 85 |
|
| 86 |
@implementation UsesProtocolWithValue |
| 87 |
@synthesize value=_value; |
| 88 |
- (unsigned) value |
| 89 |
{ |
| 90 |
return _value; |
| 91 |
} |
| 92 |
- (void) setValue:(unsigned)value |
| 93 |
{ |
| 94 |
_value = value; |
| 95 |
} |
| 96 |
@end |
| 97 |
|
| 98 |
|
| 99 |
@interface UsesInterveningProtocol : NSObject <InterveningProtocol> |
| 100 |
@end |
| 101 |
|
| 102 |
@implementation UsesInterveningProtocol |
| 103 |
|
| 104 |
@synthesize value=_value; |
| 105 |
- (unsigned) value |
| 106 |
{ |
| 107 |
return _value; |
| 108 |
} |
| 109 |
- (void) setValue:(unsigned)value |
| 110 |
{ |
| 111 |
_value = value; |
| 112 |
} |
| 113 |
@end |