summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-06-02 11:15:04 -0700
committerGitHub <noreply@github.com>2017-06-02 11:15:04 -0700
commit4eb81f6cf14b02e77f84f6a5a89d926d4eac535f (patch)
treed9425c73bee4578037b62b9793d839508e9a74e8 /src
parent6611f548cc1e6b373693cde09e9a7379659e8832 (diff)
downloadbinaryen-4eb81f6cf14b02e77f84f6a5a89d926d4eac535f.tar.gz
binaryen-4eb81f6cf14b02e77f84f6a5a89d926d4eac535f.tar.bz2
binaryen-4eb81f6cf14b02e77f84f6a5a89d926d4eac535f.zip
validate returned values in all cases, even if the function returns none we should still not have returns with a value, etc. update spec tests to remove some stacky tests that do not fit these new validation rules (#1034)
Diffstat (limited to 'src')
-rw-r--r--src/wasm-validator.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/wasm-validator.h b/src/wasm-validator.h
index d14a56a10..04c42e4f2 100644
--- a/src/wasm-validator.h
+++ b/src/wasm-validator.h
@@ -491,8 +491,8 @@ public:
if (curr->value) {
if (returnType == unreachable) {
returnType = curr->value->type;
- } else if (curr->value->type != unreachable && returnType != curr->value->type) {
- returnType = none; // poison
+ } else if (curr->value->type != unreachable) {
+ shouldBeEqual(curr->value->type, returnType, curr, "function results must match");
}
} else {
returnType = none;
@@ -560,10 +560,8 @@ public:
if (curr->body->type != unreachable) {
shouldBeEqual(curr->result, curr->body->type, curr->body, "function body type must match, if function returns");
}
- if (curr->result != none) { // TODO: over previous too?
- if (returnType != unreachable) {
- shouldBeEqual(curr->result, returnType, curr->body, "function result must match, if function returns");
- }
+ if (returnType != unreachable) {
+ shouldBeEqual(curr->result, returnType, curr->body, "function result must match, if function has returns");
}
returnType = unreachable;
labelNames.clear();