Skip to content

Commit

Permalink
c-writer.cc: Correctly handle label names when branching out of try b…
Browse files Browse the repository at this point in the history
…lock
  • Loading branch information
keithw committed Apr 21, 2023
1 parent 4134f24 commit 5e2136b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/c-writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2822,7 +2822,7 @@ void CWriter::WriteTryCatch(const TryExpr& tryexpr) {
Write(CloseBrace(), Newline()); /* end of try-catch */

ResetTypeStack(mark);
Write(LabelDecl(label_stack_.back().name));
Write(LabelDecl(GetLocalName(tryexpr.block.label, true)));
PopLabel();
PushTypes(tryexpr.block.decl.sig.result_types);
}
Expand Down Expand Up @@ -2924,7 +2924,7 @@ void CWriter::WriteTryDelegate(const TryExpr& tryexpr) {

PopTryCatch();
ResetTypeStack(mark);
Write(LabelDecl(label_stack_.back().name));
Write(LabelDecl(GetLocalName(tryexpr.block.label, true)));
PopLabel();
PushTypes(tryexpr.block.decl.sig.result_types);
}
Expand Down
12 changes: 12 additions & 0 deletions test/regress/wasm2c-try-br.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
;;; TOOL: run-spec-wasm2c
;;; ARGS: --debug-names --enable-exceptions
(module
(func (export "break-try")
(try (do (br 0)) (delegate 0))
)
)

(assert_return (invoke "break-try"))
(;; STDOUT ;;;
1/1 tests passed.
;;; STDOUT ;;)

0 comments on commit 5e2136b

Please sign in to comment.