Skip to content

Commit

Permalink
[flang] Detect fir.class nested in fir.box as invalid element type
Browse files Browse the repository at this point in the history
Catch invalid element type in fir.box in the verifier so
it does not propagate later in lowering.

Reviewed By: PeteSteinfeld

Differential Revision: https://reviews.llvm.org/D146078
  • Loading branch information
clementval committed Mar 15, 2023
1 parent 4e3608b commit 94d9b7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions flang/lib/Optimizer/Dialect/FIRType.cpp
Expand Up @@ -456,6 +456,8 @@ static bool cannotBePointerOrHeapElementType(mlir::Type eleTy) {
mlir::LogicalResult
fir::BoxType::verify(llvm::function_ref<mlir::InFlightDiagnostic()> emitError,
mlir::Type eleTy) {
if (eleTy.isa<fir::BaseBoxType>())
return emitError() << "invalid element type\n";
// TODO
return mlir::success();
}
Expand Down
5 changes: 5 additions & 0 deletions flang/test/Fir/invalid-types.fir
Expand Up @@ -167,3 +167,8 @@ func.func private @oth3() -> !fir.vector<10:>

// expected-error@+1 {{invalid element type}}
func.func private @upe() -> !fir.class<!fir.box<i32>>

// -----

// expected-error@+1 {{invalid element type}}
func.func private @upe() -> !fir.box<!fir.class<none>>

0 comments on commit 94d9b7c

Please sign in to comment.