]> granicus.if.org Git - clang/commitdiff
Objective-C [qoi]. If property is going to be implemented
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 29 Aug 2014 20:29:31 +0000 (20:29 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 29 Aug 2014 20:29:31 +0000 (20:29 +0000)
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

lib/Sema/SemaObjCProperty.cpp
test/Analysis/objc_invalidation.m
test/SemaObjC/default-synthesize.m

index ba698c1b3c3bd6aa19820ffcfaf3adcc114f47eb..cf9010f7fe0b13bf4d52e4d9f3fdc6d4fa357eba 100644 (file)
@@ -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<ObjCProtocolDecl>(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) &&
index 0d97b2952deebd36bcf472f09d241233f86d707b..cd66444f40107de7814d9e06b5b17ec5ee186532 100644 (file)
@@ -199,7 +199,7 @@ extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1,
 // synthesized in the parent, let the parent invalidate it.
 
 @protocol IDEBuildable <NSObject>
-@property (readonly, strong) id <Invalidation2> ObjB; // expected-note {{property declared here}}
+@property (readonly, strong) id <Invalidation2> ObjB;
 @end
 
 @interface Parent : NSObject <IDEBuildable, Invalidation2> {
@@ -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
 } 
index d0d3085ba7049673300436e9bdb438f76bc6ff6c..3f0ae0261daf4bb4d0e18bffaf5f72401d1068b9 100644 (file)
@@ -88,7 +88,7 @@
 @end
 
 @protocol TopProtocol
-  @property (readonly) id myString; // expected-note {{property declared here}}
+  @property (readonly) id myString;
 @end
 
 @interface TopClass <TopProtocol> 
 @interface SubClass : TopClass <TopProtocol>
 @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
 
 @implementation TimeZoneManager
 @end
+
+// rdar://18179833
+@protocol BaseProt
+@property (assign) id prot;
+@end
+
+@interface Base<BaseProt>
+@end
+
+@interface I : Base<BaseProt>
+@end
+
+@implementation I
+@end