summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index c6d679a24..80c54abed 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -1363,6 +1363,7 @@ void FunctionValidator::validateMemBytes(uint8_t bytes,
case Type::funcref:
case Type::externref:
case Type::exnref:
+ case Type::anyref:
case Type::none:
WASM_UNREACHABLE("unexpected type");
}
@@ -2176,6 +2177,7 @@ void FunctionValidator::validateAlignment(
case Type::funcref:
case Type::externref:
case Type::exnref:
+ case Type::anyref:
case Type::none:
WASM_UNREACHABLE("invalid type");
}
@@ -2475,6 +2477,20 @@ static void validateModule(Module& module, ValidationInfo& info) {
}
}
+static void validateFeatures(Module& module, ValidationInfo& info) {
+ if (module.features.hasAnyref()) {
+ info.shouldBeTrue(module.features.hasReferenceTypes(),
+ module.features,
+ "--enable-anyref requires --enable-reference-types");
+ }
+ if (module.features.hasExceptionHandling()) { // implies exnref
+ info.shouldBeTrue(
+ module.features.hasReferenceTypes(),
+ module.features,
+ "--enable-exception-handling requires --enable-reference-types");
+ }
+}
+
// TODO: If we want the validator to be part of libwasm rather than libpasses,
// then Using PassRunner::getPassDebug causes a circular dependence. We should
// fix that, perhaps by moving some of the pass infrastructure into libsupport.
@@ -2495,6 +2511,7 @@ bool WasmValidator::validate(Module& module, Flags flags) {
validateTable(module, info);
validateEvents(module, info);
validateModule(module, info);
+ validateFeatures(module, info);
}
// validate additional internal IR details when in pass-debug mode
if (PassRunner::getPassDebug()) {