[cfe-commits] r144118 - in /cfe/trunk: lib/Sema/SemaObjCProperty.cpp test/ARCMT/assign-prop-with-arc-runtime.m test/ARCMT/assign-prop-with-arc-runtime.m.result test/SemaObjC/arc.m

Fariborz Jahanian fjahanian at apple.com
Tue Nov 8 12:58:54 PST 2011


Author: fjahanian
Date: Tue Nov  8 14:58:53 2011
New Revision: 144118

URL: http://llvm.org/viewvc/llvm-project?rev=144118&view=rev
Log:
objc-arc: 'readonly' property of retainable object
type is strong by default too. // rdar://10410903

Modified:
    cfe/trunk/lib/Sema/SemaObjCProperty.cpp
    cfe/trunk/test/ARCMT/assign-prop-with-arc-runtime.m
    cfe/trunk/test/ARCMT/assign-prop-with-arc-runtime.m.result
    cfe/trunk/test/SemaObjC/arc.m

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=144118&r1=144117&r2=144118&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Nov  8 14:58:53 2011
@@ -1770,13 +1770,12 @@
                       ObjCDeclSpec::DQ_PR_unsafe_unretained |
                       ObjCDeclSpec::DQ_PR_retain | ObjCDeclSpec::DQ_PR_strong |
                       ObjCDeclSpec::DQ_PR_weak)) &&
-      !(Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
       PropertyTy->isObjCObjectPointerType()) {
       if (getLangOptions().ObjCAutoRefCount)
         // With arc,  @property definitions should default to (strong) when 
-        // not specified
+        // not specified; including when property is 'readonly'.
         PropertyDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_strong);
-      else {
+      else if (!(Attributes & ObjCDeclSpec::DQ_PR_readonly)) {
           // Skip this warning in gc-only mode.
           if (getLangOptions().getGC() != LangOptions::GCOnly)
             Diag(Loc, diag::warn_objc_property_no_assignment_attribute);

Modified: cfe/trunk/test/ARCMT/assign-prop-with-arc-runtime.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/assign-prop-with-arc-runtime.m?rev=144118&r1=144117&r2=144118&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/assign-prop-with-arc-runtime.m (original)
+++ cfe/trunk/test/ARCMT/assign-prop-with-arc-runtime.m Tue Nov  8 14:58:53 2011
@@ -14,7 +14,8 @@
 @class Forw;
 
 @interface Foo : NSObject {
-  Foo *x, *w, *q1, *q2;
+  Foo *w, *q1, *q2;
+  __weak Foo *x;
   WeakOptOut *oo;
   BadClassForWeak bcw;
   id not_safe1;
@@ -22,7 +23,7 @@
   Forw *not_safe3;
   Foo *assign_plus1;
 }
- at property (readonly) Foo *x;
+ at property (readonly) __weak Foo *x;
 @property (assign) Foo *w;
 @property Foo *q1, *q2;
 @property (assign) WeakOptOut *oo;

Modified: cfe/trunk/test/ARCMT/assign-prop-with-arc-runtime.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/assign-prop-with-arc-runtime.m.result?rev=144118&r1=144117&r2=144118&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/assign-prop-with-arc-runtime.m.result (original)
+++ cfe/trunk/test/ARCMT/assign-prop-with-arc-runtime.m.result Tue Nov  8 14:58:53 2011
@@ -14,7 +14,8 @@
 @class Forw;
 
 @interface Foo : NSObject {
-  Foo *__weak x, *__weak w, *__weak q1, *__weak q2;
+  Foo *__weak w, *__weak q1, *__weak q2;
+  __weak Foo *x;
   WeakOptOut *__unsafe_unretained oo;
   BadClassForWeak __unsafe_unretained bcw;
   id __unsafe_unretained not_safe1;
@@ -22,7 +23,7 @@
   Forw *__unsafe_unretained not_safe3;
   Foo *assign_plus1;
 }
- at property (readonly) Foo *x;
+ at property (readonly) __weak Foo *x;
 @property (weak) Foo *w;
 @property (weak) Foo *q1, *q2;
 @property (unsafe_unretained) WeakOptOut *oo;

Modified: cfe/trunk/test/SemaObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc.m?rev=144118&r1=144117&r2=144118&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc.m (original)
+++ cfe/trunk/test/SemaObjC/arc.m Tue Nov  8 14:58:53 2011
@@ -502,18 +502,18 @@
   id myProp2;
 }
 @property id x;
- at property (readonly) id ro; // expected-note {{declared here}}
+ at property (readonly) id ro;
 @property (readonly) id custom_ro;
 @property int y;
 
- at property (readonly) id myProp1;
+ at property (readonly) __weak id myProp1;
 @property (readonly) id myProp2;
 @property (readonly) __strong id myProp3;
 @end
 
 @implementation Test27
 @synthesize x;
- at synthesize ro; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute}}
+ at synthesize ro;
 @synthesize y;
 
 @synthesize myProp1 = _myProp1;





More information about the cfe-commits mailing list