diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-07-26 21:48:26 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-07-26 21:48:26 +0000 |
commit | 473506bd9dfd84944c2c5ca2c2a38814f46febc6 (patch) | |
tree | f5dcf13bcb50a2397397a4b812038d25abdd652e /lib/Sema/SemaObjCProperty.cpp | |
parent | b025734047dd8b630c34cea53b371361adb2a65a (diff) |
In ARC we emit an error when compiling:
@interface Foo : NSObject
@property (readonly) id myProp;
@end
@implementation Foo
@synthesize myProp;
@end
t.m:9:13: error: ARC forbids synthesizing a property of an Objective-C object with unspecified storage attribute
@synthesize myProp;
^
which is fine, we want the ownership of the synthesized ivar to be explicit. But we should _not_ emit an error
for the following cases, because we can get the ownership either from the declared ivar or from the property type:
@interface Foo : NSObject {
__weak id _myProp1;
id myProp2;
}
@property (readonly) id myProp1;
@property (readonly) id myProp2;
@property (readonly) __strong id myProp3;
@end
@implementation Foo
@synthesize myProp1 = _myProp1;
@synthesize myProp2;
@synthesize myProp3;
@end

rdar://9844006.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136155 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaObjCProperty.cpp')
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 53de50c16c..8c8af1389b 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -594,13 +594,6 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, ObjCIvarDecl *Ivar = 0; // Check that we have a valid, previously declared ivar for @synthesize if (Synthesize) { - if (getLangOptions().ObjCAutoRefCount && - !property->hasWrittenStorageAttribute() && - property->getType()->isObjCRetainableType()) { - Diag(PropertyLoc, diag::err_arc_objc_property_default_assign_on_object); - Diag(property->getLocation(), diag::note_property_declare); - } - // @synthesize if (!PropertyIvar) PropertyIvar = PropertyId; @@ -619,6 +612,13 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S, if (getLangOptions().ObjCAutoRefCount && !PropertyIvarType.getObjCLifetime()) { + if (!property->hasWrittenStorageAttribute() && + property->getType()->isObjCRetainableType()) { + Diag(PropertyLoc, + diag::err_arc_objc_property_default_assign_on_object); + Diag(property->getLocation(), diag::note_property_declare); + } + // retain/copy have retaining lifetime. if (kind & (ObjCPropertyDecl::OBJC_PR_retain | ObjCPropertyDecl::OBJC_PR_strong | |