diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2013-08-14 23:58:55 +0000 |
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-08-14 23:58:55 +0000 |
| commit | 8181caa44ed14be2eaa8ddacb17e5264012020c0 (patch) | |
| tree | 09a4459ecee532e29fbeaff570f2456eb2547ca3 | |
| parent | 9d8103de7ace78b609c3320244f38240c1299374 (diff) | |
| download | bcm5719-llvm-8181caa44ed14be2eaa8ddacb17e5264012020c0.tar.gz bcm5719-llvm-8181caa44ed14be2eaa8ddacb17e5264012020c0.zip | |
ObjectiveC [Sema]. This patch makes sure that all inherited
properties (direct or indirect) setter/getter (or declared
methods as well) are seen by the method implementation type
matching logic before declaration of method in super class
is seen. This fixes the warning coming out of that method mismatch.
// rdar://14650159
llvm-svn: 188438
| -rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 10 | ||||
| -rw-r--r-- | clang/test/SemaObjC/method-conflict-2.m | 49 |
2 files changed, 59 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 93620a1d82c..aa6eff700d7 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -1773,6 +1773,16 @@ void Sema::MatchAllMethodDeclarations(const SelectorSet &InsMap, } } + if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl> (CDecl)) { + // Also, check for methods declared in protocols inherited by + // this protocol. + for (ObjCProtocolDecl::protocol_iterator + PI = PD->protocol_begin(), E = PD->protocol_end(); PI != E; ++PI) + MatchAllMethodDeclarations(InsMap, ClsMap, InsMapSeen, ClsMapSeen, + IMPDecl, (*PI), IncompleteImpl, false, + WarnCategoryMethodImpl); + } + if (ObjCInterfaceDecl *I = dyn_cast<ObjCInterfaceDecl> (CDecl)) { // when checking that methods in implementation match their declaration, // i.e. when WarnCategoryMethodImpl is false, check declarations in class diff --git a/clang/test/SemaObjC/method-conflict-2.m b/clang/test/SemaObjC/method-conflict-2.m index ec80a433cc7..47c3d6c2c23 100644 --- a/clang/test/SemaObjC/method-conflict-2.m +++ b/clang/test/SemaObjC/method-conflict-2.m @@ -64,3 +64,52 @@ typedef long long int64_t; return 0; } @end + +// rdar://14650159 +// Tests that property inherited indirectly from a nested protocol +// is seen by the method implementation type matching logic before +// method in super class is seen. This fixes the warning coming +// out of that method mismatch. +@interface NSObject (NSDict) +- (void)setValue:(id)value; +- (id)value; +@end + +@protocol ProtocolWithValue +@property (nonatomic) unsigned value; +@end + +@protocol InterveningProtocol <ProtocolWithValue> +@end + +@interface UsesProtocolWithValue : NSObject <ProtocolWithValue> +@end + +@implementation UsesProtocolWithValue +@synthesize value=_value; +- (unsigned) value +{ + return _value; +} +- (void) setValue:(unsigned)value +{ + _value = value; +} +@end + + +@interface UsesInterveningProtocol : NSObject <InterveningProtocol> +@end + +@implementation UsesInterveningProtocol + +@synthesize value=_value; +- (unsigned) value +{ + return _value; +} +- (void) setValue:(unsigned)value +{ + _value = value; +} +@end |

