[flang] Fix the vector version of EOSHIFT with a BOUNDARY argument
When the vector version of EOSHIFT was called, the BOUNDARY argument was being
ignored. I fixed that and added a test that would not pass without this fix.
Differential Revision: https://reviews.llvm.org/D108249
GitOrigin-RevId: b8ecdcdd817cfe8ef187503726400971357c6854
diff --git a/runtime/transformational.cpp b/runtime/transformational.cpp
index 3fc294b..1bf9338 100644
--- a/runtime/transformational.cpp
+++ b/runtime/transformational.cpp
@@ -284,6 +284,8 @@
SubscriptValue sourceAt{lb + j - 1 + shift};
if (sourceAt >= lb && sourceAt < lb + extent) {
CopyElement(result, &j, source, &sourceAt, terminator);
+ } else if (boundary) {
+ CopyElement(result, &j, *boundary, 0, terminator);
}
}
}
diff --git a/unittests/Runtime/Transformational.cpp b/unittests/Runtime/Transformational.cpp
index 1394e53..52e0b7e 100644
--- a/unittests/Runtime/Transformational.cpp
+++ b/unittests/Runtime/Transformational.cpp
@@ -110,6 +110,26 @@
*result.ZeroBasedIndexedElement<std::int32_t>(j), eoshiftExpect1[j]);
}
result.Destroy();
+
+ // VECTOR EOSHIFT
+ StaticDescriptor<0> boundaryDescriptor;
+ Descriptor vectorBoundary{boundaryDescriptor.descriptor()};
+ std::int32_t boundaryValue{343};
+ vectorBoundary.Establish(TypeCategory::Integer, 4,
+ const_cast<void *>(reinterpret_cast<const void *>(&boundaryValue)), 0);
+ RTNAME(EoshiftVector)
+ (vectorResult, *vector, 2, &vectorBoundary, __FILE__, __LINE__);
+ EXPECT_EQ(vectorResult.type(), array->type());
+ EXPECT_EQ(vectorResult.rank(), 1);
+ EXPECT_EQ(vectorResult.GetDimension(0).LowerBound(), 1);
+ EXPECT_EQ(vectorResult.GetDimension(0).Extent(), 6);
+ EXPECT_EQ(vectorResult.type(), (TypeCode{TypeCategory::Integer, 4}));
+ static std::int32_t eoshiftVectorExpect[6]{3, 4, 5, 6, 343, 343};
+ for (int j{0}; j < 6; ++j) {
+ EXPECT_EQ(*vectorResult.ZeroBasedIndexedElement<std::int32_t>(j),
+ eoshiftVectorExpect[j]);
+ }
+ vectorResult.Destroy();
}
TEST(Transformational, Pack) {