diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-10-02 18:02:06 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-10-02 18:02:06 +0000 |
commit | a4275d194b656867bdcdb725b2a7ba3251a1a638 (patch) | |
tree | d647bb786811ca0cd1eaada8d8276df47bd25d73 /lib/CodeGen/CGStmt.cpp | |
parent | 8e45f73bae2f0a3bef2b6172cd48f3049cc4d5b1 (diff) |
Emit error unsupported for break/continue/goto inside Obj-C exception
handling blocks.
- This has false positives, but at least prevents miscompiles.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56958 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 96550d6d53..f70b86661d 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -70,8 +70,24 @@ void CodeGenFunction::EmitStmt(const Stmt *S) { case Stmt::ReturnStmtClass: EmitReturnStmt(cast<ReturnStmt>(*S)); break; case Stmt::DeclStmtClass: EmitDeclStmt(cast<DeclStmt>(*S)); break; - case Stmt::BreakStmtClass: EmitBreakStmt(); break; - case Stmt::ContinueStmtClass: EmitContinueStmt(); break; + case Stmt::BreakStmtClass: + // FIXME: Implement break in @try or @catch blocks. + if (!ObjCEHStack.empty()) { + CGM.ErrorUnsupported(S, "continue inside an Obj-C exception block"); + return; + } + EmitBreakStmt(); + break; + + case Stmt::ContinueStmtClass: + // FIXME: Implement continue in @try or @catch blocks. + if (!ObjCEHStack.empty()) { + CGM.ErrorUnsupported(S, "continue inside an Obj-C exception block"); + return; + } + EmitContinueStmt(); + break; + case Stmt::SwitchStmtClass: EmitSwitchStmt(cast<SwitchStmt>(*S)); break; case Stmt::DefaultStmtClass: EmitDefaultStmt(cast<DefaultStmt>(*S)); break; case Stmt::CaseStmtClass: EmitCaseStmt(cast<CaseStmt>(*S)); break; @@ -168,6 +184,12 @@ void CodeGenFunction::EmitLabelStmt(const LabelStmt &S) { } void CodeGenFunction::EmitGotoStmt(const GotoStmt &S) { + // FIXME: Implement goto out in @try or @catch blocks. + if (!ObjCEHStack.empty()) { + CGM.ErrorUnsupported(&S, "goto inside an Obj-C exception block"); + return; + } + Builder.CreateBr(getBasicBlockForLabel(S.getLabel())); // Emit a block after the branch so that dead code after a goto has some place @@ -176,6 +198,12 @@ void CodeGenFunction::EmitGotoStmt(const GotoStmt &S) { } void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) { + // FIXME: Implement indirect goto in @try or @catch blocks. + if (!ObjCEHStack.empty()) { + CGM.ErrorUnsupported(&S, "goto inside an Obj-C exception block"); + return; + } + // Emit initial switch which will be patched up later by // EmitIndirectSwitches(). We need a default dest, so we use the // current BB, but this is overwritten. |