Skip to content

Commit 4b84b66

Browse files
committed
Disallow empty function bodies
1 parent c744a53 commit 4b84b66

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

mlir/lib/Dialect/EmitC/IR/EmitC.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,10 @@ LogicalResult FuncOp::verify() {
436436
if (getNumResults() > 1)
437437
return emitOpError("requires zero or exactly one result, but has ")
438438
<< getNumResults();
439+
440+
if (isExternal())
441+
return emitOpError("does not support empty function bodies");
442+
439443
return success();
440444
}
441445

mlir/test/Dialect/EmitC/invalid_ops.mlir

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,8 @@ func.func @return_inside_func.func(%0: i32) -> (i32) {
321321

322322
// expected-error@+1 {{expected non-function type}}
323323
emitc.func @func_variadic(...)
324+
325+
// -----
326+
327+
// expected-error@+1 {{'emitc.func' op does not support empty function bodies}}
328+
emitc.func private @empty()

0 commit comments

Comments
 (0)