From: Fariborz Jahanian Date: Fri, 29 Aug 2014 20:29:31 +0000 (+0000) Subject: Objective-C [qoi]. If property is going to be implemented X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a7de8ad38e9611db357e9c76f230ef60d1d789f;p=clang Objective-C [qoi]. If property is going to be implemented in the super class, do not issue the warning about property in current class's protocol will not be auto synthesized. // rdar://18179833 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216769 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index ba698c1b3c..cf9010f7fe 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1555,12 +1555,14 @@ void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl* IMPDecl, Diag(PID->getLocation(), diag::note_property_synthesize); continue; } + ObjCPropertyDecl *PropInSuperClass = SuperPropMap[Prop->getIdentifier()]; if (ObjCProtocolDecl *Proto = dyn_cast(Prop->getDeclContext())) { // We won't auto-synthesize properties declared in protocols. // Suppress the warning if class's superclass implements property's // getter and implements property's setter (if readwrite property). - if (!SuperClassImplementsProperty(IDecl, Prop)) { + // Or, if property is going to be implemented in its super class. + if (!SuperClassImplementsProperty(IDecl, Prop) && !PropInSuperClass) { Diag(IMPDecl->getLocation(), diag::warn_auto_synthesizing_protocol_property) << Prop << Proto; @@ -1569,8 +1571,7 @@ void Sema::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl* IMPDecl, continue; } // If property to be implemented in the super class, ignore. - if (ObjCPropertyDecl *PropInSuperClass = - SuperPropMap[Prop->getIdentifier()]) { + if (PropInSuperClass) { if ((Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_readwrite) && (PropInSuperClass->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_readonly) && diff --git a/test/Analysis/objc_invalidation.m b/test/Analysis/objc_invalidation.m index 0d97b2952d..cd66444f40 100644 --- a/test/Analysis/objc_invalidation.m +++ b/test/Analysis/objc_invalidation.m @@ -199,7 +199,7 @@ extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, // synthesized in the parent, let the parent invalidate it. @protocol IDEBuildable -@property (readonly, strong) id ObjB; // expected-note {{property declared here}} +@property (readonly, strong) id ObjB; @end @interface Parent : NSObject { @@ -231,7 +231,7 @@ extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, } @end -@implementation Child // expected-warning {{auto property synthesis will not synthesize property 'ObjB' declared in protocol 'IDEBuildable'}} +@implementation Child - (void)invalidate{ // no-warning } diff --git a/test/SemaObjC/default-synthesize.m b/test/SemaObjC/default-synthesize.m index d0d3085ba7..3f0ae0261d 100644 --- a/test/SemaObjC/default-synthesize.m +++ b/test/SemaObjC/default-synthesize.m @@ -88,7 +88,7 @@ @end @protocol TopProtocol - @property (readonly) id myString; // expected-note {{property declared here}} + @property (readonly) id myString; @end @interface TopClass @@ -100,7 +100,7 @@ @interface SubClass : TopClass @end -@implementation SubClass @end // expected-warning {{auto property synthesis will not synthesize property 'myString' declared in protocol 'TopProtocol'}} +@implementation SubClass @end // rdar://7920807 @interface C @end @@ -160,3 +160,17 @@ @implementation TimeZoneManager @end + +// rdar://18179833 +@protocol BaseProt +@property (assign) id prot; +@end + +@interface Base +@end + +@interface I : Base +@end + +@implementation I +@end