diff options
-rw-r--r-- | include/clang/Parse/Action.h | 2 | ||||
-rw-r--r-- | lib/Parse/ParseObjc.cpp | 1 | ||||
-rw-r--r-- | lib/Sema/Sema.h | 1 | ||||
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 13 | ||||
-rw-r--r-- | test/CodeGenObjC/blocks-4.m | 21 |
5 files changed, 38 insertions, 0 deletions
diff --git a/include/clang/Parse/Action.h b/include/clang/Parse/Action.h index 6b398f62f6..91854aa480 100644 --- a/include/clang/Parse/Action.h +++ b/include/clang/Parse/Action.h @@ -459,6 +459,8 @@ public: virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D) { return DeclPtrTy(); } + virtual void ActOnObjCCatchParam(DeclPtrTy D) { + } /// AddInitializerToDecl - This action is called immediately after /// ActOnDeclarator (when an initializer is present). The code is factored diff --git a/lib/Parse/ParseObjc.cpp b/lib/Parse/ParseObjc.cpp index ae85aa3a8a..e837c765bf 100644 --- a/lib/Parse/ParseObjc.cpp +++ b/lib/Parse/ParseObjc.cpp @@ -1482,6 +1482,7 @@ Parser::OwningStmtResult Parser::ParseObjCTryStmt(SourceLocation atLoc) { // Inform the actions module about the parameter declarator, so it // gets added to the current scope. FirstPart = Actions.ActOnParamDeclarator(CurScope, ParmDecl); + Actions.ActOnObjCCatchParam(FirstPart); } else ConsumeToken(); // consume '...' diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index d971b9caeb..b8831b4b7a 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -676,6 +676,7 @@ public: bool &OverloadableAttrRequired); void CheckMain(FunctionDecl *FD); virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D); + virtual void ActOnObjCCatchParam(DeclPtrTy D); virtual void ActOnParamDefaultArgument(DeclPtrTy param, SourceLocation EqualLoc, ExprArg defarg); diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index c604f6a4ee..8c217f8e0d 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3934,6 +3934,19 @@ Sema::ActOnParamDeclarator(Scope *S, Declarator &D) { return DeclPtrTy::make(New); } +void Sema::ActOnObjCCatchParam(DeclPtrTy D) { + ParmVarDecl *Param = cast<ParmVarDecl>(D.getAs<Decl>()); + + if (FunctionDecl *Function = dyn_cast<FunctionDecl>(CurContext)) + Param->setDeclContext(Function); + else if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(CurContext)) + Param->setDeclContext(MD); + else if (BlockDecl *BD = dyn_cast<BlockDecl>(CurContext)) + Param->setDeclContext(BD); + // FIXME. Other contexts? + +} + void Sema::ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls) { assert(D.getTypeObject(0).Kind == DeclaratorChunk::Function && diff --git a/test/CodeGenObjC/blocks-4.m b/test/CodeGenObjC/blocks-4.m new file mode 100644 index 0000000000..d945ed44fa --- /dev/null +++ b/test/CodeGenObjC/blocks-4.m @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -fblocks -o %t %s +// rdar://7590273 + +void EXIT(id e); + +@interface NSBlockOperation { +} ++(id)blockOperationWithBlock:(void (^)(void))block ; +@end + +void FUNC() { + [NSBlockOperation blockOperationWithBlock:^{ + @try { + + } + @catch (id exception) { + EXIT(exception); + } + }]; + +} |