Skip to content

Commit c25bd6e

Browse files
authored
[flang][runtime] Teach ApplyType to handle TypeCategory::Unsigned (#123058)
1 parent 7881ac9 commit c25bd6e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

flang/runtime/tools.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,23 @@ inline RT_API_ATTRS RESULT ApplyType(
206206
default:
207207
terminator.Crash("not yet implemented: INTEGER(KIND=%d)", kind);
208208
}
209+
case TypeCategory::Unsigned:
210+
switch (kind) {
211+
case 1:
212+
return FUNC<TypeCategory::Unsigned, 1>{}(std::forward<A>(x)...);
213+
case 2:
214+
return FUNC<TypeCategory::Unsigned, 2>{}(std::forward<A>(x)...);
215+
case 4:
216+
return FUNC<TypeCategory::Unsigned, 4>{}(std::forward<A>(x)...);
217+
case 8:
218+
return FUNC<TypeCategory::Unsigned, 8>{}(std::forward<A>(x)...);
219+
#if defined __SIZEOF_INT128__ && !AVOID_NATIVE_UINT128_T
220+
case 16:
221+
return FUNC<TypeCategory::Unsigned, 16>{}(std::forward<A>(x)...);
222+
#endif
223+
default:
224+
terminator.Crash("not yet implemented: UNSIGNED(KIND=%d)", kind);
225+
}
209226
case TypeCategory::Real:
210227
switch (kind) {
211228
#if 0 // TODO: REAL(2 & 3)

flang/unittests/Runtime/Support.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,14 @@ TEST(IsAssumedSize, Basic) {
6767
std::vector<int>{}, std::vector<std::int32_t>{0})};
6868
EXPECT_FALSE(RTNAME(IsAssumedSize)(*scalar));
6969
}
70+
71+
TEST(DescriptorBytesFor, Basic) {
72+
for (size_t i = 0; i < Fortran::common::TypeCategory_enumSize; ++i) {
73+
auto tc{static_cast<TypeCategory>(i)};
74+
if (tc == TypeCategory::Derived)
75+
continue;
76+
77+
auto b{Descriptor::BytesFor(tc, 4)};
78+
EXPECT_GT(b, 0U);
79+
}
80+
}

0 commit comments

Comments
 (0)