diff options
-rw-r--r-- | src/s2wasm.h | 4 | ||||
-rw-r--r-- | test/dot_s/return.s | 17 | ||||
-rw-r--r-- | test/dot_s/return.wast | 12 |
3 files changed, 33 insertions, 0 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h index 67ec557ef..9afa51c7f 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -1002,6 +1002,10 @@ class S2WasmBuilder { abort_on("function element"); } } + if (!estack.empty()) { + addToBlock(estack.back()); + estack.pop_back(); + } // finishing touches bstack.back()->cast<Block>()->finalize(); bstack.pop_back(); // remove the base block for the function body diff --git a/test/dot_s/return.s b/test/dot_s/return.s new file mode 100644 index 000000000..5a0bded5a --- /dev/null +++ b/test/dot_s/return.s @@ -0,0 +1,17 @@ + .text + .globl return_i32 + .type return_i32,@function +return_i32: + .result i32 + i32.const $push0=, 5 + .endfunc +.Lfunc_end0: + .size return_i32, .Lfunc_end0-return_i32 + + .globl return_void + .type return_void,@function +return_void: + .endfunc +.Lfunc_end0: + .size return_void, .Lfunc_end0-return_void + diff --git a/test/dot_s/return.wast b/test/dot_s/return.wast new file mode 100644 index 000000000..421ee48c0 --- /dev/null +++ b/test/dot_s/return.wast @@ -0,0 +1,12 @@ +(module + (memory 1) + (export "memory" memory) + (export "return_i32" $return_i32) + (export "return_void" $return_void) + (func $return_i32 (result i32) + (i32.const 5) + ) + (func $return_void + ) +) +;; METADATA: { "asmConsts": {},"staticBump": 12, "initializers": [] } |