Skip to content

[flang] Extension intrinsics INT8 and INT2 #109433

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
Sep 20, 2024
Merged

Conversation

klausler
Copy link
Contributor

These are legacy conversion intrinsic functions supported by nearly all Fortran compilers (esp. INT8).
They are equivalent to INT(..., KIND=8 or 2), respectively.

These are legacy conversion intrinsic functions supported
by nearly all Fortran compilers (esp. INT8).
They are equivalent to INT(..., KIND=8 or 2), respectively.
@klausler klausler requested a review from jeanPerier September 20, 2024 14:46
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Sep 20, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 20, 2024

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

These are legacy conversion intrinsic functions supported by nearly all Fortran compilers (esp. INT8).
They are equivalent to INT(..., KIND=8 or 2), respectively.


Full diff: https://github.com/llvm/llvm-project/pull/109433.diff

2 Files Affected:

  • (modified) flang/lib/Evaluate/intrinsics.cpp (+6)
  • (added) flang/test/Evaluate/int8.f90 (+5)
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 166dae93178c51..26661d9d534b3d 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1169,6 +1169,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

@klausler klausler requested a review from vdonaldson September 20, 2024 16:55
@klausler klausler merged commit 6959ec9 into llvm:main Sep 20, 2024
11 checks passed
@klausler klausler deleted the bug36348 branch September 20, 2024 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants