Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions flang-rt/lib/runtime/support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ bool RTDEF(IsContiguous)(const Descriptor &descriptor) {
return descriptor.IsContiguous();
}

bool RTDEF(IsContiguousUpTo)(const Descriptor &descriptor, char dim) {
return descriptor.IsContiguous(dim);
}

bool RTDEF(IsAssumedSize)(const Descriptor &descriptor) {
return ISO::IsAssumedSize(&descriptor.raw());
}
Expand Down
20 changes: 20 additions & 0 deletions flang-rt/unittests/Runtime/Support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,23 @@ TEST(DescriptorBytesFor, Basic) {
EXPECT_GT(b, 0U);
}
}

TEST(IsContiguous, Basic) {
// ARRAY 1 3 5
// 2 4 6
auto array{MakeArray<TypeCategory::Integer, 4>(
std::vector<int>{2, 3}, std::vector<std::int32_t>{1, 2, 3, 4, 5, 6})};
StaticDescriptor<2> sectionStaticDesc;
Descriptor &section{sectionStaticDesc.descriptor()};
section.Establish(array->type(), array->ElementBytes(),
/*p=*/nullptr, /*rank=*/2);
static const SubscriptValue lbs[]{1, 1}, ubs[]{2, 3}, strides[]{1, 2};
const auto error{
CFI_section(&section.raw(), &array->raw(), lbs, ubs, strides)};
ASSERT_EQ(error, 0) << "CFI_section failed for array: " << error;

EXPECT_TRUE(RTNAME(IsContiguous)(*array));
EXPECT_FALSE(RTNAME(IsContiguous)(section));
EXPECT_TRUE(RTNAME(IsContiguousUpTo)(section, 1));
EXPECT_FALSE(RTNAME(IsContiguousUpTo)(section, 2));
}