[flang] Detect fir.class nested in fir.box as invalid element type

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
This commit is contained in:
Valentin Clement 2023-03-15 17:35:00 +01:00
parent 4e3608bf29
commit 94d9b7ce60
No known key found for this signature in database
GPG Key ID: 086D54783C928776
2 changed files with 7 additions and 0 deletions

View File

@ -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();
}

View File

@ -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>>