Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/fuzz_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ def is_git_repo():
'shared-types-no-gc.wast',
'shared-ref-i31.wast',
'table-type.wast',
'elem-type.wast',
]


Expand Down
8 changes: 8 additions & 0 deletions src/wasm/wasm-validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3877,6 +3877,14 @@ static void validateTables(Module& module, ValidationInfo& info) {
segment->type.isNullable(),
"elem",
"Non-nullable reference types are not yet supported for tables");
auto typeFeats = segment->type.getFeatures();
if (!info.shouldBeTrue(
segment->type == funcref || typeFeats <= module.features,
"elem",
"element segment type requires additional features")) {
info.getStream(nullptr)
<< getMissingFeaturesList(module, typeFeats) << '\n';
}

bool isPassive = !segment->table.is();
if (isPassive) {
Expand Down
12 changes: 12 additions & 0 deletions test/lit/validation/elem-type.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
;; Test that the features required by element segment types are checked

;; RUN: not wasm-opt %s -all --disable-shared-everything 2>&1 | filecheck %s --check-prefix NO-SHARED
;; RUN: wasm-opt %s -all -S -o - | filecheck %s --check-prefix SHARED

;; NO-SHARED: element segment type requires additional features
;; NO-SHARED: [--enable-shared-everything]
;; SHARED: (elem $e (ref null (shared func)))

(module
(elem $e (ref null (shared func)))
)