diff options
author | Thomas Lively <tlively@google.com> | 2024-02-07 15:04:51 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-07 15:04:51 -0800 |
commit | d4c3fddd3de605983398756d3b46e2f14e55aba2 (patch) | |
tree | d64c2d8ee79a5d204345f3ca1588ccbd4239f1cc /src | |
parent | f12977dd8aae5a0a42e65a8e448bca1453f018c6 (diff) | |
download | binaryen-d4c3fddd3de605983398756d3b46e2f14e55aba2.tar.gz binaryen-d4c3fddd3de605983398756d3b46e2f14e55aba2.tar.bz2 binaryen-d4c3fddd3de605983398756d3b46e2f14e55aba2.zip |
Get more tests working with the new text parser (#6284)
The new parser enforces the rule that imports must come before declarations
(except for type declarations). The old parser does not enforce this rule, so
many of our tests did not follow it. Fix them to follow that rule and fix other
invalid syntax. Also add missing finalization of Load expressions in
wasm-builder.h that was causing a test to fail under the new parser and guard
against an error case in wasm-ir-builder.cpp that used to cause a segfault.
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-builder.h | 1 | ||||
-rw-r--r-- | src/wasm/wasm-ir-builder.cpp | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/src/wasm-builder.h b/src/wasm-builder.h index 4b5df766d..3096ada07 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -362,6 +362,7 @@ public: ret->ptr = ptr; ret->type = type; ret->memory = memory; + ret->finalize(); return ret; } Load* makeAtomicLoad( diff --git a/src/wasm/wasm-ir-builder.cpp b/src/wasm/wasm-ir-builder.cpp index f8c8cf0a0..8098856e4 100644 --- a/src/wasm/wasm-ir-builder.cpp +++ b/src/wasm/wasm-ir-builder.cpp @@ -677,6 +677,9 @@ Result<Expression*> IRBuilder::finishScope(Block* block) { } else { auto hoisted = hoistLastValue(); CHECK_ERR(hoisted); + if (!hoisted) { + return Err{"popping from empty stack"}; + } auto hoistedType = scope.exprStack.back()->type; if (hoistedType.size() != type.size()) { // We cannot propagate the hoisted value directly because it does not |