summaryrefslogtreecommitdiff
path: root/test/gtest/validator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/gtest/validator.cpp')
-rw-r--r--test/gtest/validator.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/gtest/validator.cpp b/test/gtest/validator.cpp
index 87d698e56..99d5878ae 100644
--- a/test/gtest/validator.cpp
+++ b/test/gtest/validator.cpp
@@ -48,3 +48,20 @@ TEST(ValidatorTest, MissingCatchTag) {
WasmValidator::FlagValues::Globally | WasmValidator::FlagValues::Quiet;
EXPECT_FALSE(validator.validate(&function, module, flags));
}
+
+TEST(ValidatorTest, ReturnUnreachable) {
+ Module module;
+ Builder builder(module);
+
+ // (return (unreachable)) should be invalid if a function has no return type.
+ auto func =
+ builder.makeFunction("func",
+ {},
+ Signature(Type::none, Type::none),
+ {},
+ builder.makeReturn(builder.makeUnreachable()));
+
+ auto flags =
+ WasmValidator::FlagValues::Globally | WasmValidator::FlagValues::Quiet;
+ EXPECT_FALSE(WasmValidator{}.validate(func.get(), module, flags));
+}