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);
@class Forw;
@interface Foo : NSObject {
- Foo *x, *w, *q1, *q2;
+ Foo *w, *q1, *q2;
+ __weak Foo *x;
WeakOptOut *oo;
BadClassForWeak bcw;
id not_safe1;
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;
@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;
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;
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;