summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Gohman <sunfish@mozilla.com>2016-05-19 17:05:58 -0700
committerDan Gohman <sunfish@mozilla.com>2016-05-19 17:05:58 -0700
commit373cfe3a4364d657b04ea9c35e84324e9edec097 (patch)
tree31d5b392aab63be53f202e57aaca3ef098e3dc44
parente396635727ca7fd571aa4fd19ba310942767307e (diff)
downloadbinaryen-373cfe3a4364d657b04ea9c35e84324e9edec097.tar.gz
binaryen-373cfe3a4364d657b04ea9c35e84324e9edec097.tar.bz2
binaryen-373cfe3a4364d657b04ea9c35e84324e9edec097.zip
Allow implicit function returns. (#529)
-rw-r--r--src/s2wasm.h4
-rw-r--r--test/dot_s/return.s17
-rw-r--r--test/dot_s/return.wast12
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": [] }