diff options
-rw-r--r-- | src/c-writer.cc | 8 | ||||
-rw-r--r-- | test/regress/wasm2c-try-br.txt | 12 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/c-writer.cc b/src/c-writer.cc index 588151fd..89c676c4 100644 --- a/src/c-writer.cc +++ b/src/c-writer.cc @@ -2837,7 +2837,9 @@ void CWriter::WriteTryCatch(const TryExpr& tryexpr) { Write(CloseBrace(), Newline()); /* end of try-catch */ ResetTypeStack(mark); - Write(LabelDecl(label_stack_.back().name)); + assert(!label_stack_.empty()); + assert(label_stack_.back().name == tryexpr.block.label); + Write(LabelDecl(GetLocalName(tryexpr.block.label, true))); PopLabel(); PushTypes(tryexpr.block.decl.sig.result_types); } @@ -2939,7 +2941,9 @@ void CWriter::WriteTryDelegate(const TryExpr& tryexpr) { PopTryCatch(); ResetTypeStack(mark); - Write(LabelDecl(label_stack_.back().name)); + assert(!label_stack_.empty()); + assert(label_stack_.back().name == tryexpr.block.label); + Write(LabelDecl(GetLocalName(tryexpr.block.label, true))); PopLabel(); PushTypes(tryexpr.block.decl.sig.result_types); } diff --git a/test/regress/wasm2c-try-br.txt b/test/regress/wasm2c-try-br.txt new file mode 100644 index 00000000..53aaaa2e --- /dev/null +++ b/test/regress/wasm2c-try-br.txt @@ -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 ;;) |