aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2012-04-20 22:00:46 +0000
committerFariborz Jahanian <fjahanian@apple.com>2012-04-20 22:00:46 +0000
commit0e78afbb15c6f51932e562e620f714c37cf914e6 (patch)
tree066087f274b98a9b8fb292e6da4443c2f1e3524d
parent0b3ade86a1c60cf0c7b56aa238aff458eb7f5974 (diff)
objective-c arc: With currnt documentation,
objc_returns_inner_pointer attribute can be applied to methods only. Diagnsose otherwise, instead of crashing. // rdar://11253688 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155245 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaDeclAttr.cpp4
-rw-r--r--test/SemaObjC/arc-property-lifetime.m5
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 3770b3c373..9004508a47 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -3334,8 +3334,8 @@ static void handleObjCReturnsInnerPointerAttr(Sema &S, Decl *D,
ObjCMethodDecl *method = dyn_cast<ObjCMethodDecl>(D);
- if (!isa<ObjCMethodDecl>(method)) {
- S.Diag(method->getLocStart(), diag::err_attribute_wrong_decl_type)
+ if (!method || !isa<ObjCMethodDecl>(method)) {
+ S.Diag(D->getLocStart(), diag::err_attribute_wrong_decl_type)
<< SourceRange(loc, loc) << attr.getName() << ExpectedMethod;
return;
}
diff --git a/test/SemaObjC/arc-property-lifetime.m b/test/SemaObjC/arc-property-lifetime.m
index fad37ccbf4..bd393e0bf5 100644
--- a/test/SemaObjC/arc-property-lifetime.m
+++ b/test/SemaObjC/arc-property-lifetime.m
@@ -168,3 +168,8 @@ void foo(Baz *f) {
f.realy_strong_attr_prop = [[Baz alloc] init];
f.implicit = [[Baz alloc] init];
}
+
+// rdar://11253688
+@interface Boom
+@property (readonly) const void * innerPointer __attribute__((objc_returns_inner_pointer)); // expected-error {{'objc_returns_inner_pointer' attribute only applies to methods}}
+@end