From 0e78afbb15c6f51932e562e620f714c37cf914e6 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Fri, 20 Apr 2012 22:00:46 +0000 Subject: [PATCH] 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 --- lib/Sema/SemaDeclAttr.cpp | 4 ++-- test/SemaObjC/arc-property-lifetime.m | 5 +++++ 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(D); - if (!isa(method)) { - S.Diag(method->getLocStart(), diag::err_attribute_wrong_decl_type) + if (!method || !isa(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 -- 2.40.0