summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-08-19 19:28:44 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-08-19 19:28:44 +0000
commit7e47de3156b038aa0bd5f215aaa6886a1a7ea8a9 (patch)
tree6924dab8d0cda9d1a51d02a05a7deaa561da0665
parent7c4739da3cb88a1e2b20859e1db8f9df15876961 (diff)
downloadbcm5719-llvm-7e47de3156b038aa0bd5f215aaa6886a1a7ea8a9.tar.gz
bcm5719-llvm-7e47de3156b038aa0bd5f215aaa6886a1a7ea8a9.zip
objc-arc: @property definitions should default to (strong) when not
specified. // rdar://9971982 llvm-svn: 138062
-rw-r--r--clang/lib/Sema/SemaObjCProperty.cpp21
-rw-r--r--clang/test/CodeGenObjC/arc.m16
-rw-r--r--clang/test/SemaObjC/arc.m6
3 files changed, 32 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp
index 9602c2bd5b6..1d0b5eff906 100644
--- a/clang/lib/Sema/SemaObjCProperty.cpp
+++ b/clang/lib/Sema/SemaObjCProperty.cpp
@@ -605,7 +605,8 @@ Decl *Sema::ActOnPropertyImplDecl(Scope *S,
!PropertyIvarType.getObjCLifetime()) {
if (!property->hasWrittenStorageAttribute() &&
- property->getType()->isObjCRetainableType()) {
+ property->getType()->isObjCRetainableType() &&
+ !(kind & ObjCPropertyDecl::OBJC_PR_strong) ) {
Diag(PropertyLoc,
diag::err_arc_objc_property_default_assign_on_object);
Diag(property->getLocation(), diag::note_property_declare);
@@ -1707,13 +1708,19 @@ void Sema::CheckObjCPropertyAttributes(Decl *PDecl,
ObjCDeclSpec::DQ_PR_weak)) &&
!(Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
PropertyTy->isObjCObjectPointerType()) {
- // Skip this warning in gc-only mode.
- if (getLangOptions().getGCMode() != LangOptions::GCOnly)
- Diag(Loc, diag::warn_objc_property_no_assignment_attribute);
+ if (getLangOptions().ObjCAutoRefCount)
+ // With arc, @property definitions should default to (strong) when
+ // not specified
+ PropertyDecl->setPropertyAttributes(ObjCPropertyDecl::OBJC_PR_strong);
+ else {
+ // Skip this warning in gc-only mode.
+ if (getLangOptions().getGCMode() != LangOptions::GCOnly)
+ Diag(Loc, diag::warn_objc_property_no_assignment_attribute);
- // If non-gc code warn that this is likely inappropriate.
- if (getLangOptions().getGCMode() == LangOptions::NonGC)
- Diag(Loc, diag::warn_objc_property_default_assign_on_object);
+ // If non-gc code warn that this is likely inappropriate.
+ if (getLangOptions().getGCMode() == LangOptions::NonGC)
+ Diag(Loc, diag::warn_objc_property_default_assign_on_object);
+ }
// FIXME: Implement warning dependent on NSCopying being
// implemented. See also:
diff --git a/clang/test/CodeGenObjC/arc.m b/clang/test/CodeGenObjC/arc.m
index 7883b0ebaf7..154918bb5b5 100644
--- a/clang/test/CodeGenObjC/arc.m
+++ b/clang/test/CodeGenObjC/arc.m
@@ -1839,3 +1839,19 @@ void test62(void) {
// CHECK: ret void
}
+
+// rdar://9971982
+@class NSString;
+
+@interface Person {
+ NSString *name;
+}
+@property NSString *address;
+@end
+
+@implementation Person
+@synthesize address;
+@end
+// CHECK: call i8* @objc_getProperty
+// CHECK: call void @objc_setProperty
+
diff --git a/clang/test/SemaObjC/arc.m b/clang/test/SemaObjC/arc.m
index 83835ebd03f..15ce0e2f6eb 100644
--- a/clang/test/SemaObjC/arc.m
+++ b/clang/test/SemaObjC/arc.m
@@ -491,9 +491,7 @@ void test26(id y) {
__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 id x;
@property (readonly) id ro; // expected-note {{declared here}}
@property (readonly) id custom_ro;
@property int y;
@@ -504,7 +502,7 @@ void test26(id y) {
@end
@implementation Test27
-@synthesize x; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute}}
+@synthesize x;
@synthesize ro; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified ownership or storage attribute}}
@synthesize y;
OpenPOWER on IntegriCloud