Don't crash when a statement in a block is ill-formed but

introduces cleanups anyway.

llvm-svn: 152345
This commit is contained in:
John McCall 2012-03-08 22:00:17 +00:00
parent 812924502b
commit 85110b47c8
2 changed files with 15 additions and 0 deletions

View File

@ -8892,6 +8892,8 @@ ExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
Diag(CaretLoc, diag::err_blocks_disable);
// Leave the expression-evaluation context.
if (hasAnyUnrecoverableErrorsInThisFunction())
DiscardCleanupsInEvaluationContext();
assert(!ExprNeedsCleanups && "cleanups within block not correctly bound!");
PopExpressionEvaluationContext();

View File

@ -0,0 +1,13 @@
// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fblocks -verify %s
// rdar://problem/10982793
// [p foo] in ARC creates a cleanup.
// The plus is invalid and causes the cleanup to go unbound.
// Don't crash.
@interface A
- (id) foo;
@end
void takeBlock(void (^)(void));
void test0(id p) {
takeBlock(^{ [p foo] + p; }); // expected-error {{invalid operands to binary expression}}
}