Skip to content

[flang][runtime] Teach ApplyType to handle TypeCategory::Unsigned #123058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2025
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
17 changes: 17 additions & 0 deletions flang/runtime/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,23 @@ inline RT_API_ATTRS RESULT ApplyType(
default:
terminator.Crash("not yet implemented: INTEGER(KIND=%d)", kind);
}
case TypeCategory::Unsigned:
switch (kind) {
case 1:
return FUNC<TypeCategory::Unsigned, 1>{}(std::forward<A>(x)...);
case 2:
return FUNC<TypeCategory::Unsigned, 2>{}(std::forward<A>(x)...);
case 4:
return FUNC<TypeCategory::Unsigned, 4>{}(std::forward<A>(x)...);
case 8:
return FUNC<TypeCategory::Unsigned, 8>{}(std::forward<A>(x)...);
#if defined __SIZEOF_INT128__ && !AVOID_NATIVE_UINT128_T
case 16:
return FUNC<TypeCategory::Unsigned, 16>{}(std::forward<A>(x)...);
#endif
default:
terminator.Crash("not yet implemented: UNSIGNED(KIND=%d)", kind);
}
case TypeCategory::Real:
switch (kind) {
#if 0 // TODO: REAL(2 & 3)
Expand Down
11 changes: 11 additions & 0 deletions flang/unittests/Runtime/Support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,14 @@ TEST(IsAssumedSize, Basic) {
std::vector<int>{}, std::vector<std::int32_t>{0})};
EXPECT_FALSE(RTNAME(IsAssumedSize)(*scalar));
}

TEST(DescriptorBytesFor, Basic) {
for (size_t i = 0; i < Fortran::common::TypeCategory_enumSize; ++i) {
auto tc{static_cast<TypeCategory>(i)};
if (tc == TypeCategory::Derived)
continue;

auto b{Descriptor::BytesFor(tc, 4)};
EXPECT_GT(b, 0U);
}
}
Loading