]> granicus.if.org Git - clang/commitdiff
Assortment of property attributes declared in continuation
authorFariborz Jahanian <fjahanian@apple.com>
Tue, 3 Nov 2009 00:01:38 +0000 (00:01 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Tue, 3 Nov 2009 00:01:38 +0000 (00:01 +0000)
class must match those of same property declared
in its primary class. (Fixes radar 7352425)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85843 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclObjC.cpp
test/SemaObjC/continuation-class-err.m

index f9f01681b93d6996721c39f2fed85a6eee90fde6..46c6bf45ad1a8703f80eee0259a87b7ff734909b 100644 (file)
@@ -1900,9 +1900,16 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc,
           // with continuation class's readwrite property attribute!
           unsigned PIkind = PIDecl->getPropertyAttributes();
           if (isReadWrite && (PIkind & ObjCPropertyDecl::OBJC_PR_readonly)) {
-            if ((Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) !=
-                (PIkind & ObjCPropertyDecl::OBJC_PR_nonatomic))
+            unsigned assignRetainCopyNonatomic = 
+              (ObjCPropertyDecl::OBJC_PR_assign |
+               ObjCPropertyDecl::OBJC_PR_retain |
+               ObjCPropertyDecl::OBJC_PR_copy |
+               ObjCPropertyDecl::OBJC_PR_nonatomic);
+            if ((Attributes & assignRetainCopyNonatomic) !=
+                (PIkind & assignRetainCopyNonatomic)) {
               Diag(AtLoc, diag::warn_property_attr_mismatch);
+              Diag(PIDecl->getLocation(), diag::note_property_declare);
+            }
             PIDecl->makeitReadWriteAttribute();
             if (Attributes & ObjCDeclSpec::DQ_PR_retain)
               PIDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_retain);
index e1ae39bd2942a30326c4f2e9282c04a59bbdf0e4..262b786b5408216c44b72f4a7c5e9859b86f56b8 100644 (file)
@@ -5,12 +5,12 @@
   id _object;
   id _object1;
 }
-@property(readonly) id object;
+@property(readonly) id object; // expected-note {{property declared here}}
 @property(readwrite, assign) id object1; // expected-note {{property declared here}}
 @end
 
 @interface ReadOnly ()
-@property(readwrite, copy) id object;  
+@property(readwrite, copy) id object;  // expected-warning {{property attribute in continuation class does not match the primary class}}
 @property(readonly) id object1; // expected-error {{property declaration in continuation class of 'ReadOnly' is to change a 'readonly' property to 'readwrite'}}
 @end