[MLIR] Flag no-terminator error on the last operation of non-empty blocks

- When a block is not empty and does not end with a terminator, flag the error on the
  last operation of the block instead of the start of the block.

Differential Revision: https://reviews.llvm.org/D90988
This commit is contained in:
Rahul Joshi 2020-11-06 16:24:35 -08:00
parent e625f9c5d1
commit c96168975b
2 changed files with 3 additions and 2 deletions

View File

@ -148,7 +148,7 @@ LogicalResult OperationVerifier::verifyBlock(Block &block) {
if (failed(verifyOperation(block.back())))
return failure();
if (block.back().isKnownNonTerminator())
return emitError(block, "block with no terminator");
return block.back().emitError("block with no terminator");
// Verify that this block is not branching to a block of a different
// region.

View File

@ -170,7 +170,8 @@ func @block_first_has_predecessor() {
// -----
func @no_return() {
%x = constant 0 : i32 // expected-error {{block with no terminator}}
%x = constant 0 : i32
%y = constant 1 : i32 // expected-error {{block with no terminator}}
}
// -----