Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions flang/lib/Optimizer/Dialect/FIROps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1774,12 +1774,13 @@ llvm::LogicalResult fir::CoordinateOp::verify() {
return emitOpError("too many operands for len_param_index case");
}
if (eleTy != index.getOnType())
emitOpError(
return emitOpError(
"len_param_index type not compatible with reference type");
return mlir::success();
} else if (auto index = mlir::dyn_cast<fir::FieldIndexOp>(defOp)) {
if (eleTy != index.getOnType())
emitOpError("field_index type not compatible with reference type");
return emitOpError(
"field_index type not compatible with reference type");
if (auto recTy = mlir::dyn_cast<fir::RecordType>(eleTy)) {
eleTy = recTy.getType(index.getFieldName());
continue;
Expand Down Expand Up @@ -3406,26 +3407,30 @@ llvm::LogicalResult fir::SaveResultOp::verify() {
auto eleTy = resultType;
if (auto seqTy = mlir::dyn_cast<fir::SequenceType>(resultType)) {
if (seqTy.getDimension() != shapeTyRank)
emitOpError("shape operand must be provided and have the value rank "
"when the value is a fir.array");
return emitOpError(
"shape operand must be provided and have the value rank "
"when the value is a fir.array");
eleTy = seqTy.getEleTy();
} else {
if (shapeTyRank != 0)
emitOpError(
return emitOpError(
"shape operand should only be provided if the value is a fir.array");
}

if (auto recTy = mlir::dyn_cast<fir::RecordType>(eleTy)) {
if (recTy.getNumLenParams() != getTypeparams().size())
emitOpError("length parameters number must match with the value type "
"length parameters");
return emitOpError(
"length parameters number must match with the value type "
"length parameters");
} else if (auto charTy = mlir::dyn_cast<fir::CharacterType>(eleTy)) {
if (getTypeparams().size() > 1)
emitOpError("no more than one length parameter must be provided for "
"character value");
return emitOpError(
"no more than one length parameter must be provided for "
"character value");
} else {
if (!getTypeparams().empty())
emitOpError("length parameters must not be provided for this value type");
return emitOpError(
"length parameters must not be provided for this value type");
}

return mlir::success();
Expand Down
10 changes: 6 additions & 4 deletions flang/lib/Optimizer/Dialect/FortranVariableInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,19 @@ fir::FortranVariableOpInterface::verifyDeclareLikeOpImpl(mlir::Value memref) {
shapeRank = shapeShiftType.getRank();
} else {
if (!sourceIsBoxValue)
emitOpError("of array entity with a raw address base must have a "
"shape operand that is a shape or shapeshift");
return emitOpError(
"of array entity with a raw address base must have a "
"shape operand that is a shape or shapeshift");
shapeRank = mlir::cast<fir::ShiftType>(shape.getType()).getRank();
}

std::optional<unsigned> rank = getRank();
if (!rank || *rank != shapeRank)
return emitOpError("has conflicting shape and base operand ranks");
} else if (!sourceIsBox) {
emitOpError("of array entity with a raw address base must have a shape "
"operand that is a shape or shapeshift");
return emitOpError(
"of array entity with a raw address base must have a shape "
"operand that is a shape or shapeshift");
}
}
return mlir::success();
Expand Down