[flang-commits] [flang] [Flang] - Handle `BoxCharType` in `fir.box_offset` op (PR #141713)
via flang-commits
flang-commits at lists.llvm.org
Mon Jun 2 04:02:31 PDT 2025
================
@@ -4484,15 +4484,26 @@ void fir::IfOp::resultToSourceOps(llvm::SmallVectorImpl<mlir::Value> &results,
llvm::LogicalResult fir::BoxOffsetOp::verify() {
auto boxType = mlir::dyn_cast_or_null<fir::BaseBoxType>(
fir::dyn_cast_ptrEleTy(getBoxRef().getType()));
- if (!boxType)
- return emitOpError("box_ref operand must have !fir.ref<!fir.box<T>> type");
+ mlir::Type boxCharType;
+ bool isBoxChar = false;
+ if (!boxType) {
+ boxCharType = mlir::dyn_cast_or_null<fir::BoxCharType>(
+ fir::dyn_cast_ptrEleTy(getBoxRef().getType()));
+ if (!boxCharType)
+ return emitOpError("box_ref operand must have !fir.ref<!fir.box<T>> or "
+ "!fir.ref<!fir.boxchar<k>> type");
+ isBoxChar = true;
+ }
if (getField() != fir::BoxFieldAttr::base_addr &&
getField() != fir::BoxFieldAttr::derived_type)
return emitOpError("cannot address provided field");
- if (getField() == fir::BoxFieldAttr::derived_type)
+ if (getField() == fir::BoxFieldAttr::derived_type) {
+ if (isBoxChar)
+ return emitOpError("cannot address derived_type field of a fir.boxchar");
----------------
jeanPerier wrote:
nit: moving this checks under the `if (!boxType) {` and removing the isBoxChar would simplify the reading for me.
https://github.com/llvm/llvm-project/pull/141713
More information about the flang-commits
mailing list