diff options
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 3 | ||||
-rw-r--r-- | test/CodeGenObjC/arc-with-atthrow.m | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 65f431d460..7acfc985db 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -2154,6 +2154,7 @@ Sema::ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, StmtResult Sema::BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw) { if (Throw) { + Throw = MaybeCreateExprWithCleanups(Throw); ExprResult Result = DefaultLvalueConversion(Throw); if (Result.isInvalid()) return StmtError(); @@ -2188,7 +2189,7 @@ Sema::ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, if (!AtCatchParent) return StmtError(Diag(AtLoc, diag::error_rethrow_used_outside_catch)); } - + return BuildObjCAtThrowStmt(AtLoc, Throw); } diff --git a/test/CodeGenObjC/arc-with-atthrow.m b/test/CodeGenObjC/arc-with-atthrow.m new file mode 100644 index 0000000000..b076879bdd --- /dev/null +++ b/test/CodeGenObjC/arc-with-atthrow.m @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-nonfragile-abi -fobjc-exceptions -o - %s | FileCheck %s +// $CLANG -cc1 -fobjc-arc -fobjc-nonfragile-abi -fobjc-exceptions +// pr10411 + +@interface NSException ++ (id)exception; +@end + +void test() +{ + @throw [NSException exception]; +} + +// CHECK: objc_retainAutoreleasedReturnValue +// CHECK: call void @objc_release +// CHECK: call void @objc_exception_throw |