Skip to content

Commit 1ace281

Browse files
committed
Add assert for array size
1 parent 54da0d4 commit 1ace281

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

flang/lib/Optimizer/CodeGen/Target.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,8 @@ struct TargetX86_64Win : public GenericTarget<TargetX86_64Win> {
788788
//===----------------------------------------------------------------------===//
789789

790790
namespace {
791+
// AArch64 procedure call standard:
792+
// https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#parameter-passing
791793
struct TargetAArch64 : public GenericTarget<TargetAArch64> {
792794
using GenericTarget::GenericTarget;
793795

@@ -917,6 +919,8 @@ struct TargetAArch64 : public GenericTarget<TargetAArch64> {
917919
.Case<fir::LogicalType>([&](auto) { return NRegs{1, false}; })
918920
.Case<fir::CharacterType>([&](auto) { return NRegs{1, false}; })
919921
.Case<fir::SequenceType>([&](auto ty) {
922+
assert(ty.getShape().size() == 1 &&
923+
"invalid array dimensions in BIND(C)");
920924
NRegs nregs = usedRegsForType(loc, ty.getEleTy());
921925
nregs.n *= ty.getShape()[0];
922926
return nregs;
@@ -970,8 +974,6 @@ struct TargetAArch64 : public GenericTarget<TargetAArch64> {
970974
return marshal;
971975
}
972976

973-
// AArch64 procedure call ABI:
974-
// https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#parameter-passing
975977
CodeGenSpecifics::Marshalling
976978
structType(mlir::Location loc, fir::RecordType type, bool isResult) const {
977979
NRegs nregs = usedRegsForRecordType(loc, type);

0 commit comments

Comments
 (0)