diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-11-08 20:58:53 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-11-08 20:58:53 +0000 |
commit | f21a92d35953adb038ffbe37cd1a4083e0df0ec0 (patch) | |
tree | 6d345ce9c429137693f82972c411862dc1fafb4a | |
parent | 4c11772bb9e1bf7fb0cdf8fd3566314ef91baf8c (diff) |
objc-arc: 'readonly' property of retainable object
type is strong by default too. // rdar://10410903
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144118 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 5 | ||||
-rw-r--r-- | test/ARCMT/assign-prop-with-arc-runtime.m | 5 | ||||
-rw-r--r-- | test/ARCMT/assign-prop-with-arc-runtime.m.result | 5 | ||||
-rw-r--r-- | test/SemaObjC/arc.m | 6 |
4 files changed, 11 insertions, 10 deletions
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 46b2a086dd..4933f001c4 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -1770,13 +1770,12 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl, 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); diff --git a/test/ARCMT/assign-prop-with-arc-runtime.m b/test/ARCMT/assign-prop-with-arc-runtime.m index 8408a1858b..8845010895 100644 --- a/test/ARCMT/assign-prop-with-arc-runtime.m +++ b/test/ARCMT/assign-prop-with-arc-runtime.m @@ -14,7 +14,8 @@ typedef _NSCachedAttributedString *BadClassForWeak; @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 @@ typedef _NSCachedAttributedString *BadClassForWeak; Forw *not_safe3; Foo *assign_plus1; } -@property (readonly) Foo *x; +@property (readonly) __weak Foo *x; @property (assign) Foo *w; @property Foo *q1, *q2; @property (assign) WeakOptOut *oo; diff --git a/test/ARCMT/assign-prop-with-arc-runtime.m.result b/test/ARCMT/assign-prop-with-arc-runtime.m.result index e6070a86b7..2c67f18180 100644 --- a/test/ARCMT/assign-prop-with-arc-runtime.m.result +++ b/test/ARCMT/assign-prop-with-arc-runtime.m.result @@ -14,7 +14,8 @@ typedef _NSCachedAttributedString *BadClassForWeak; @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 @@ typedef _NSCachedAttributedString *BadClassForWeak; Forw *__unsafe_unretained not_safe3; Foo *assign_plus1; } -@property (readonly) Foo *x; +@property (readonly) __weak Foo *x; @property (weak) Foo *w; @property (weak) Foo *q1, *q2; @property (unsafe_unretained) WeakOptOut *oo; diff --git a/test/SemaObjC/arc.m b/test/SemaObjC/arc.m index d146d8fad1..c0393c46cc 100644 --- a/test/SemaObjC/arc.m +++ b/test/SemaObjC/arc.m @@ -502,18 +502,18 @@ void test26(id y) { id myProp2; } @property id x; -@property (readonly) id ro; // expected-note {{declared here}} +@property (readonly) id ro; @property (readonly) id custom_ro; @property int y; -@property (readonly) id myProp1; +@property (readonly) __weak id myProp1; @property (readonly) id myProp2; @property (readonly) __strong id myProp3; @end @implementation Test27 @synthesize x; -@synthesize ro; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute}} +@synthesize ro; @synthesize y; @synthesize myProp1 = _myProp1; |