diff options
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 91e7e7398..5c0e0d542 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -235,6 +235,7 @@ public: void visitSwitch(Switch* curr); void visitCall(Call* curr); void visitCallIndirect(CallIndirect* curr); + void visitConst(Const* curr); void visitGetLocal(GetLocal* curr); void visitSetLocal(SetLocal* curr); void visitGetGlobal(GetGlobal* curr); @@ -475,6 +476,11 @@ void FunctionValidator::visitCallIndirect(CallIndirect* curr) { } } +void FunctionValidator::visitConst(Const* curr) { + shouldBeTrue(getFeatures(curr->type) <= info.features, curr, + "all used features should be allowed"); +} + void FunctionValidator::visitGetLocal(GetLocal* curr) { shouldBeTrue(curr->index < getFunction()->getNumLocals(), curr, "local.get index must be small enough"); shouldBeTrue(isConcreteType(curr->type), curr, "local.get must have a valid type - check what you provided when you constructed the node"); @@ -1270,6 +1276,8 @@ static void validateExports(Module& module, ValidationInfo& info) { static void validateGlobals(Module& module, ValidationInfo& info) { ModuleUtils::iterDefinedGlobals(module, [&](Global* curr) { + info.shouldBeTrue(getFeatures(curr->type) <= info.features, curr->name, + "all used types should be allowed"); info.shouldBeTrue(curr->init != nullptr, curr->name, "global init must be non-null"); info.shouldBeTrue(curr->init->is<Const>() || curr->init->is<GetGlobal>(), curr->name, "global init must be valid"); if (!info.shouldBeEqual(curr->type, curr->init->type, curr->init, "global init must have correct type") && !info.quiet) { |