diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shared-validator.cc | 1 | ||||
-rw-r--r-- | src/validator.cc | 10 | ||||
-rw-r--r-- | src/wast-parser.cc | 1 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/shared-validator.cc b/src/shared-validator.cc index 68630182..5d9de4fe 100644 --- a/src/shared-validator.cc +++ b/src/shared-validator.cc @@ -461,6 +461,7 @@ Result SharedValidator::BeginFunctionBody(const Location& loc, } Result SharedValidator::EndFunctionBody(const Location& loc) { + expr_loc_ = loc; return typechecker_.EndFunction(); } diff --git a/src/validator.cc b/src/validator.cc index b3f231bd..6e52d262 100644 --- a/src/validator.cc +++ b/src/validator.cc @@ -816,16 +816,18 @@ Result Validator::CheckModule() { Index func_index = module->num_func_imports; for (const ModuleField& field : module->fields) { if (auto* f = dyn_cast<FuncModuleField>(&field)) { - result_ |= validator_.BeginFunctionBody(field.loc, func_index++); + const Location& body_start = f->func.loc; + const Location& body_end = + f->func.exprs.empty() ? body_start : f->func.exprs.back().loc; + result_ |= validator_.BeginFunctionBody(body_start, func_index++); for (auto&& decl : f->func.local_types.decls()) { - // TODO: Better location? - result_ |= validator_.OnLocalDecl(field.loc, decl.second, decl.first); + result_ |= validator_.OnLocalDecl(body_start, decl.second, decl.first); } ExprVisitor visitor(this); result_ |= visitor.VisitExprList(const_cast<ExprList&>(f->func.exprs)); - result_ |= validator_.EndFunctionBody(field.loc); + result_ |= validator_.EndFunctionBody(body_end); } } diff --git a/src/wast-parser.cc b/src/wast-parser.cc index f07ee8b1..80b47858 100644 --- a/src/wast-parser.cc +++ b/src/wast-parser.cc @@ -1361,6 +1361,7 @@ Result WastParser::ParseFuncModuleField(Module* module) { } else { auto field = MakeUnique<FuncModuleField>(loc, name); Func& func = field->func; + func.loc = GetLocation(); CHECK_RESULT(ParseTypeUseOpt(&func.decl)); CHECK_RESULT(ParseFuncSignature(&func.decl.sig, &func.bindings)); TypeVector local_types; |