diff options
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r-- | src/wasm/wasm-validator.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index 689872a19..f8bd08e1d 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -3701,6 +3701,25 @@ static void validateGlobals(Module& module, ValidationInfo& info) { seen.insert(curr); } }); + + // Check that globals have allowed types. + for (auto& g : module.globals) { + auto globalFeats = g->type.getFeatures(); + if (!info.shouldBeTrue(globalFeats <= module.features, g->name, "")) { + auto& stream = info.getStream(nullptr); + stream << "global type requires additional features ["; + bool first = true; + (globalFeats - module.features).iterFeatures([&](FeatureSet feat) { + if (first) { + first = false; + } else { + stream << " "; + } + stream << "--enable-" << feat.toString(); + }); + stream << "]\n"; + } + } } static void validateMemories(Module& module, ValidationInfo& info) { |