[flang-commits] [flang] 6959ec9 - [flang] Extension intrinsics INT8 and INT2 (#109433)
via flang-commits
flang-commits at lists.llvm.org
Fri Sep 20 13:53:53 PDT 2024
Author: Peter Klausler
Date: 2024-09-20T13:53:50-07:00
New Revision: 6959ec91d7f8b579a7698cfe244d434b177af493
URL: https://github.com/llvm/llvm-project/commit/6959ec91d7f8b579a7698cfe244d434b177af493
DIFF: https://github.com/llvm/llvm-project/commit/6959ec91d7f8b579a7698cfe244d434b177af493.diff
LOG: [flang] Extension intrinsics INT8 and INT2 (#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.
Added:
flang/test/Evaluate/int8.f90
Modified:
flang/lib/Evaluate/intrinsics.cpp
Removed:
################################################################################
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 637ee5b8923f19..17a09c080e72c4 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1173,6 +1173,12 @@ static const SpecificIntrinsicInterface specificIntrinsicFunction[]{
// procedure pointer target.
{{"index", {{"string", DefaultChar}, {"substring", DefaultChar}},
DefaultInt}},
+ {{"int2", {{"a", AnyNumeric, Rank::elementalOrBOZ}},
+ TypePattern{IntType, KindCode::exactKind, 2}},
+ "int"},
+ {{"int8", {{"a", AnyNumeric, Rank::elementalOrBOZ}},
+ TypePattern{IntType, KindCode::exactKind, 8}},
+ "int"},
{{"isign", {{"a", DefaultInt}, {"b", DefaultInt}}, DefaultInt}, "sign"},
{{"jiabs", {{"a", TypePattern{IntType, KindCode::exactKind, 4}}},
TypePattern{IntType, KindCode::exactKind, 4}},
diff --git a/flang/test/Evaluate/int8.f90 b/flang/test/Evaluate/int8.f90
new file mode 100644
index 00000000000000..ef8321f4c710b3
--- /dev/null
+++ b/flang/test/Evaluate/int8.f90
@@ -0,0 +1,5 @@
+! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
+!CHECK: warning: REAL(4) to INTEGER(2) conversion overflowed
+!CHECK: PRINT *, 32767_2, 4000000000_8
+print *, int2(4.e9), int8(4.e9)
+end
More information about the flang-commits
mailing list