[flang-commits] [flang] f6e8b3e - [flang] Don't convert actual argument if IGNORE_TKR is present for the corresponding dummy

Kelvin Li via flang-commits flang-commits at lists.llvm.org
Thu May 25 10:26:47 PDT 2023


Author: Kelvin Li
Date: 2023-05-25T13:26:11-04:00
New Revision: f6e8b3ec8d16e619f93001fa1ad9c428330022e7

URL: https://github.com/llvm/llvm-project/commit/f6e8b3ec8d16e619f93001fa1ad9c428330022e7
DIFF: https://github.com/llvm/llvm-project/commit/f6e8b3ec8d16e619f93001fa1ad9c428330022e7.diff

LOG: [flang] Don't convert actual argument if IGNORE_TKR is present for the corresponding dummy

This patch is to remove the conversion of the actual argument that
is associated with the dummy argument specified with the IGNORE_TKR
directive.

Commit on behalf of @danielcchen

Differential Revision: https://reviews.llvm.org/D151401

Added: 
    

Modified: 
    flang/lib/Semantics/check-call.cpp
    flang/test/Semantics/ignore_tkr02.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index fc07b8d26aceb..7b4e6e245c945 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -207,16 +207,18 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
       dummy.attrs.test(characteristics::DummyDataObject::Attr::Pointer)};
   bool dummyIsAllocatableOrPointer{dummyIsAllocatable || dummyIsPointer};
   allowActualArgumentConversions &= !dummyIsAllocatableOrPointer;
-  if (allowActualArgumentConversions) {
-    ConvertIntegerActual(actual, dummy.type, actualType, messages);
-  }
-  bool typesCompatible{
+  bool typesCompatibleWithIgnoreTKR{
       (dummy.ignoreTKR.test(common::IgnoreTKR::Type) &&
           (dummy.type.type().category() == TypeCategory::Derived ||
               actualType.type().category() == TypeCategory::Derived ||
               dummy.type.type().category() != actualType.type().category())) ||
       (dummy.ignoreTKR.test(common::IgnoreTKR::Kind) &&
-          dummy.type.type().category() == actualType.type().category()) ||
+          dummy.type.type().category() == actualType.type().category())};
+  allowActualArgumentConversions &= !typesCompatibleWithIgnoreTKR;
+  if (allowActualArgumentConversions) {
+    ConvertIntegerActual(actual, dummy.type, actualType, messages);
+  }
+  bool typesCompatible{typesCompatibleWithIgnoreTKR ||
       dummy.type.type().IsTkCompatibleWith(actualType.type())};
   if (!typesCompatible && dummy.type.Rank() == 0 &&
       allowActualArgumentConversions) {

diff  --git a/flang/test/Semantics/ignore_tkr02.f90 b/flang/test/Semantics/ignore_tkr02.f90
index a56b92d6613aa..b7cb7233c0a41 100644
--- a/flang/test/Semantics/ignore_tkr02.f90
+++ b/flang/test/Semantics/ignore_tkr02.f90
@@ -17,21 +17,21 @@ subroutine sub4(j, k)
       !dir$ ignore_tkr(kr) k
     end
   end interface
-!CHECK: CALL sub1(1_1,int(1_1,kind=4))
+!CHECK: CALL sub1(1_1,1_1)
   call generic(1_1,1_1)
-!CHECK: CALL sub1(1_1,int(1_2,kind=4))
+!CHECK: CALL sub1(1_1,1_2)
   call generic(1_1,1_2)
 !CHECK: CALL sub1(1_1,[INTEGER(1)::1_1])
   call generic(1_1,[1_1])
-!CHECK: CALL sub2(1_2,int(1_1,kind=4))
+!CHECK: CALL sub2(1_2,1_1)
   call generic(1_2,1_1)
-!CHECK: CALL sub2(1_2,int(1_2,kind=4))
+!CHECK: CALL sub2(1_2,1_2)
   call generic(1_2,1_2)
 !CHECK: CALL sub2(1_2,[INTEGER(1)::1_1])
   call generic(1_2,[1_1])
-!CHECK: CALL sub4(1_4,int(1_1,kind=4))
+!CHECK: CALL sub4(1_4,1_1)
   call generic(1_4,1_1)
-!CHECK: CALL sub4(1_4,int(1_2,kind=4))
+!CHECK: CALL sub4(1_4,1_2)
   call generic(1_4,1_2)
 !CHECK: CALL sub4(1_4,[INTEGER(1)::1_1])
   call generic(1_4,[1_1])


        


More information about the flang-commits mailing list