summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2018-10-30 12:46:31 -0700
committerGitHub <noreply@github.com>2018-10-30 12:46:31 -0700
commitbba180a8c1ea170341e8479ba6ceebeb7b97cf73 (patch)
tree72d00ba442aa5b5026914ed15457d101a117d11e /src
parent38d6ac56fc9bead682f9c09295303635aeca47d8 (diff)
downloadwabt-bba180a8c1ea170341e8479ba6ceebeb7b97cf73.tar.gz
wabt-bba180a8c1ea170341e8479ba6ceebeb7b97cf73.tar.bz2
wabt-bba180a8c1ea170341e8479ba6ceebeb7b97cf73.zip
Check type use vs. explicit sig. in call_indirect (#937)
The `call_indirect` instruction can take a type use, but can also take an explicit signature: ``` call_indirect (type $foo) ;; type use call_indirect (param i32) ;; explicit signature call_indirect (type $bar) (result f32) ;; both ``` These type signatures must match, or the wat file is considered malformed. This was properly checked in the spec tests, because it was performed in a separate function `wabt::ValidateFuncSignatures`. This wasn't validated in `wat2wasm`, because it performs the full module validation via `wabt::ValidateModule`, which doesn't share code with `ValidateFuncSignatures`. It might be a good idea to share the code between these two, but for now it's enough to fix this bug by performing the same check in the module validation path. Fixes issue #936.
Diffstat (limited to 'src')
-rw-r--r--src/validator.cc10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/validator.cc b/src/validator.cc
index 58a36cd5..08976f2a 100644
--- a/src/validator.cc
+++ b/src/validator.cc
@@ -602,10 +602,7 @@ Result Validator::OnCallIndirectExpr(CallIndirectExpr* expr) {
if (current_module_->tables.size() == 0) {
PrintError(&expr->loc, "found call_indirect operator, but no table");
}
- if (expr->decl.has_func_type) {
- const FuncType* func_type;
- CheckFuncTypeVar(&expr->decl.type_var, &func_type);
- }
+ CheckFuncSignature(&expr->loc, expr->decl);
typechecker_.OnCallIndirect(expr->decl.sig.param_types,
expr->decl.sig.result_types);
return Result::Ok;
@@ -812,10 +809,7 @@ Result Validator::OnReturnCallIndirectExpr(ReturnCallIndirectExpr* expr) {
if (current_module_->tables.empty()) {
PrintError(&expr->loc, "found return_call_indirect operator, but no table");
}
- if (expr->decl.has_func_type) {
- const FuncType* func_type;
- CheckFuncTypeVar(&expr->decl.type_var, &func_type);
- }
+ CheckFuncSignature(&expr->loc, expr->decl);
typechecker_.OnReturnCallIndirect(expr->decl.sig.param_types,
expr->decl.sig.result_types);
return Result::Ok;