[wasm] Fix validation error for missing return statement in asm.js module.

R=mstarzinger@chromium.org,bradnelson@chromium.org
LOG=Y
BUG=chromium:575364

Review URL: https://codereview.chromium.org/1564313003

Cr-Commit-Position: refs/heads/master@{#33175}
This commit is contained in:
titzer 2016-01-08 04:49:48 -08:00 committed by Commit bot
parent b111ad2138
commit cad2294e42
2 changed files with 14 additions and 0 deletions

View File

@ -127,6 +127,9 @@ void AsmTyper::VisitAsmModule(FunctionLiteral* fun) {
// Validate exports.
ReturnStatement* stmt = fun->body()->last()->AsReturnStatement();
if (stmt == nullptr) {
FAIL(fun->body()->last(), "last statement in module is not a return");
}
RECURSE(VisitWithExpectation(stmt->expression(), Type::Object(),
"expected object export"));
}

View File

@ -0,0 +1,11 @@
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-wasm
function f() {
"use asm";
}
assertThrows(function() { WASM.asmCompileRun(f.toString()); });