[cfe-commits] r152345 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaObjC/arc-invalid.m
John McCall
rjmccall at apple.com
Thu Mar 8 14:00:17 PST 2012
Author: rjmccall
Date: Thu Mar 8 16:00:17 2012
New Revision: 152345
URL: http://llvm.org/viewvc/llvm-project?rev=152345&view=rev
Log:
Don't crash when a statement in a block is ill-formed but
introduces cleanups anyway.
Added:
cfe/trunk/test/SemaObjC/arc-invalid.m
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=152345&r1=152344&r2=152345&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Mar 8 16:00:17 2012
@@ -8892,6 +8892,8 @@
Diag(CaretLoc, diag::err_blocks_disable);
// Leave the expression-evaluation context.
+ if (hasAnyUnrecoverableErrorsInThisFunction())
+ DiscardCleanupsInEvaluationContext();
assert(!ExprNeedsCleanups && "cleanups within block not correctly bound!");
PopExpressionEvaluationContext();
Added: cfe/trunk/test/SemaObjC/arc-invalid.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-invalid.m?rev=152345&view=auto
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-invalid.m (added)
+++ cfe/trunk/test/SemaObjC/arc-invalid.m Thu Mar 8 16:00:17 2012
@@ -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.
+ at interface A
+- (id) foo;
+ at end
+void takeBlock(void (^)(void));
+void test0(id p) {
+ takeBlock(^{ [p foo] + p; }); // expected-error {{invalid operands to binary expression}}
+}
More information about the cfe-commits
mailing list