diff options
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 2 | ||||
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 14 | ||||
-rw-r--r-- | test/SemaObjC/arc.m | 18 |
3 files changed, 23 insertions, 11 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index cdfa11203e..8b21362532 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -2627,7 +2627,7 @@ def err_arc_objc_object_in_struct : Error< "ARC forbids Objective-C objects in structs or unions">; def err_arc_objc_property_default_assign_on_object : Error< "ARC forbids synthesizing a property of an Objective-C object " - "with unspecified storage attribute">; + "with unspecified ownership or storage attribute">; def err_arc_illegal_selector : Error< "ARC forbids use of %0 in a @selector">; def err_arc_illegal_method_def : Error< 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 | diff --git a/test/SemaObjC/arc.m b/test/SemaObjC/arc.m index 669a92798d..1ee76ecdba 100644 --- a/test/SemaObjC/arc.m +++ b/test/SemaObjC/arc.m @@ -483,19 +483,31 @@ void test26(id y) { @end // rdar://9525555 -@interface Test27 +@interface Test27 { + __weak id _myProp1; + id myProp2; +} @property id x; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}} \ // expected-warning {{default property attribute 'assign' not appropriate for non-gc object}} \ // expected-note {{declared here}} @property (readonly) id ro; // expected-note {{declared here}} @property (readonly) id custom_ro; @property int y; + +@property (readonly) id myProp1; +@property (readonly) id myProp2; +@property (readonly) __strong id myProp3; @end @implementation Test27 -@synthesize x; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified storage attribute}} -@synthesize ro; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified storage attribute}} +@synthesize x; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute}} +@synthesize ro; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute}} @synthesize y; + +@synthesize myProp1 = _myProp1; +@synthesize myProp2; +@synthesize myProp3; + -(id)custom_ro { return 0; } @end |