diff options
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 16 | ||||
-rw-r--r-- | test/lit/array-new-fixed.wast | 36 |
2 files changed, 5 insertions, 47 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 26af9ee00..957956044 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -3161,18 +3161,12 @@ Expression* SExpressionWasmBuilder::makeArrayNewElem(Element& s) { Expression* SExpressionWasmBuilder::makeArrayNewFixed(Element& s) { auto heapType = parseHeapType(*s[1]); - size_t i = 2; - std::vector<Expression*> values; - if (i < s.size() && s[i]->isStr()) { - // With the standard syntax one should specify explicitly the size - // of the array - if ((size_t)parseIndex(*s[i]) != s.size() - 3) { - throw SParseException("wrong number of elements in array", s); - } - i++; + if ((size_t)parseIndex(*s[2]) != s.size() - 3) { + throw SParseException("wrong number of elements in array", s); } - while (i < s.size()) { - values.push_back(parseExpression(*s[i++])); + std::vector<Expression*> values; + for (size_t i = 3; i < s.size(); ++i) { + values.push_back(parseExpression(*s[i])); } return Builder(wasm).makeArrayNewFixed(heapType, values); } diff --git a/test/lit/array-new-fixed.wast b/test/lit/array-new-fixed.wast deleted file mode 100644 index 60fbc7c93..000000000 --- a/test/lit/array-new-fixed.wast +++ /dev/null @@ -1,36 +0,0 @@ -;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. -;; RUN: wasm-opt -all %s -S -o - | filecheck %s - -;; Check that we can optionally specify the size of the array. -(module - ;; CHECK: (type $array (array i32)) - (type $array (array i32)) - ;; CHECK: (func $test (type $1) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (array.new_fixed $array 2 - ;; CHECK-NEXT: (i32.const 0) - ;; CHECK-NEXT: (i32.const 1) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: (drop - ;; CHECK-NEXT: (array.new_fixed $array 2 - ;; CHECK-NEXT: (i32.const 0) - ;; CHECK-NEXT: (i32.const 1) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - ;; CHECK-NEXT: ) - (func $test - (drop - (array.new_fixed $array - (i32.const 0) - (i32.const 1) - ) - ) - (drop - (array.new_fixed $array 2 - (i32.const 0) - (i32.const 1) - ) - ) - ) -) |