[cfe-commits] r59444 - in /cfe/trunk: lib/Sema/Sema.cpp test/SemaObjC/block-ivar.m
Steve Naroff
snaroff at apple.com
Mon Nov 17 08:28:53 PST 2008
Author: snaroff
Date: Mon Nov 17 10:28:52 2008
New Revision: 59444
URL: http://llvm.org/viewvc/llvm-project?rev=59444&view=rev
Log:
Fix <rdar://problem/6320086> parser rejects block capturing ivar.
Added:
cfe/trunk/test/SemaObjC/block-ivar.m
Modified:
cfe/trunk/lib/Sema/Sema.cpp
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=59444&r1=59443&r2=59444&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Mon Nov 17 10:28:52 2008
@@ -241,5 +241,8 @@
}
ObjCMethodDecl *Sema::getCurMethodDecl() {
- return dyn_cast<ObjCMethodDecl>(CurContext);
+ DeclContext *DC = CurContext;
+ while (isa<BlockDecl>(DC))
+ DC = DC->getParent();
+ return dyn_cast<ObjCMethodDecl>(DC);
}
Added: cfe/trunk/test/SemaObjC/block-ivar.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/block-ivar.m?rev=59444&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/block-ivar.m (added)
+++ cfe/trunk/test/SemaObjC/block-ivar.m Mon Nov 17 10:28:52 2008
@@ -0,0 +1,19 @@
+// RUN: clang -fsyntax-only -verify %s
+
+ at interface NSObject {
+ struct objc_object *isa;
+}
+ at end
+ at interface Foo : NSObject {
+ int _prop;
+}
+ at end
+
+ at implementation Foo
+- (int)doSomething {
+ int (^blk)(void) = ^{ return _prop; };
+ return blk();
+}
+
+ at end
+
More information about the cfe-commits
mailing list