diff --git a/mlir/test/Analysis/invalid.mlir b/mlir/test/Analysis/invalid.mlir new file mode 100644 --- /dev/null +++ b/mlir/test/Analysis/invalid.mlir @@ -0,0 +1,7 @@ +// RUN: mlir-opt -split-input-file -pass-pipeline='builtin.module(func.func(test-foo-analysis))' %s -verify-diagnostics + +// ----- + +// expected-error @+1 {{expected at least one block in the region}} +func.func private @no_block_func_declaration() -> () + diff --git a/mlir/test/lib/Analysis/TestDataFlowFramework.cpp b/mlir/test/lib/Analysis/TestDataFlowFramework.cpp --- a/mlir/test/lib/Analysis/TestDataFlowFramework.cpp +++ b/mlir/test/lib/Analysis/TestDataFlowFramework.cpp @@ -96,6 +96,9 @@ if (top->getNumRegions() != 1) return top->emitError("expected a single region top-level op"); + if (top->getRegion(0).getBlocks().empty()) + return top->emitError("expected at least one block in the region"); + // Initialize the top-level state. getOrCreate(&top->getRegion(0).front())->join(0);