[flang][runtime] Catch EOSHIFT ARRAY/BOUNDARY type mismatch (#183168)
The ARRAY= and optional BOUNDARY= arguments to EOSHIFT must have the same dynamic type. Add a runtime check.
This commit is contained in:
parent
67eb750225
commit
7acc02ff7a
@ -583,6 +583,26 @@ void RTDEF(CshiftVector)(Descriptor &result, const Descriptor &source,
|
||||
}
|
||||
}
|
||||
|
||||
static void CheckBoundaryType(const Descriptor &array,
|
||||
const Descriptor &boundary, Terminator &terminator) {
|
||||
if (const auto *boundaryAddendum{boundary.Addendum()}) {
|
||||
if (const auto *boundaryDT{boundaryAddendum->derivedType()}) {
|
||||
if (const auto *arrayAddendum{array.Addendum()}) {
|
||||
if (const auto *arrayDT{arrayAddendum->derivedType()}) {
|
||||
if (boundaryDT != arrayDT) {
|
||||
terminator.Crash("EOSHIFT: BOUNDARY= has type '%.*s' that differs "
|
||||
"from ARRAY= type '%.*s'",
|
||||
static_cast<int>(boundaryDT->name().ElementBytes()),
|
||||
boundaryDT->name().OffsetElement(),
|
||||
static_cast<int>(arrayDT->name().ElementBytes()),
|
||||
arrayDT->name().OffsetElement());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EOSHIFT of rank > 1
|
||||
void RTDEF(Eoshift)(Descriptor &result, const Descriptor &source,
|
||||
const Descriptor &shift, const Descriptor *boundary, int dim,
|
||||
@ -621,6 +641,7 @@ void RTDEF(Eoshift)(Descriptor &result, const Descriptor &source,
|
||||
}
|
||||
}
|
||||
}
|
||||
CheckBoundaryType(source, *boundary, terminator);
|
||||
}
|
||||
ShiftControl shiftControl{shift, terminator, dim};
|
||||
shiftControl.Init(source, "EOSHIFT");
|
||||
@ -675,13 +696,13 @@ void RTDEF(EoshiftVector)(Descriptor &result, const Descriptor &source,
|
||||
if (boundary) {
|
||||
RUNTIME_CHECK(terminator, boundary->rank() == 0);
|
||||
RUNTIME_CHECK(terminator, boundary->type() == source.type());
|
||||
CheckBoundaryType(source, *boundary, terminator);
|
||||
if (boundary->ElementBytes() != elementLen) {
|
||||
terminator.Crash("EOSHIFT: BOUNDARY= has element byte length %zd but "
|
||||
"ARRAY= has length %zd",
|
||||
boundary->ElementBytes(), elementLen);
|
||||
}
|
||||
}
|
||||
if (!boundary) {
|
||||
} else {
|
||||
DefaultInitialize(result, terminator);
|
||||
}
|
||||
SubscriptValue lb{source.GetDimension(0).LowerBound()};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user