Skip to content

Commit 6959ec9

Browse files
authored
[flang] Extension intrinsics INT8 and INT2 (llvm#109433)
These are legacy conversion intrinsic functions supported by nearly all Fortran compilers (esp. INT8). They are equivalent to INT(..., KIND=8 or 2), respectively.
1 parent 8be575e commit 6959ec9

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

flang/lib/Evaluate/intrinsics.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,12 @@ static const SpecificIntrinsicInterface specificIntrinsicFunction[]{
11731173
// procedure pointer target.
11741174
{{"index", {{"string", DefaultChar}, {"substring", DefaultChar}},
11751175
DefaultInt}},
1176+
{{"int2", {{"a", AnyNumeric, Rank::elementalOrBOZ}},
1177+
TypePattern{IntType, KindCode::exactKind, 2}},
1178+
"int"},
1179+
{{"int8", {{"a", AnyNumeric, Rank::elementalOrBOZ}},
1180+
TypePattern{IntType, KindCode::exactKind, 8}},
1181+
"int"},
11761182
{{"isign", {{"a", DefaultInt}, {"b", DefaultInt}}, DefaultInt}, "sign"},
11771183
{{"jiabs", {{"a", TypePattern{IntType, KindCode::exactKind, 4}}},
11781184
TypePattern{IntType, KindCode::exactKind, 4}},

flang/test/Evaluate/int8.f90

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
2+
!CHECK: warning: REAL(4) to INTEGER(2) conversion overflowed
3+
!CHECK: PRINT *, 32767_2, 4000000000_8
4+
print *, int2(4.e9), int8(4.e9)
5+
end

0 commit comments

Comments
 (0)