[flang-commits] [flang] 099a62e - [flang] Ensure "dtv" args passed by descriptor when polymorphic

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Thu Mar 9 09:55:33 PST 2023


Author: Peter Klausler
Date: 2023-03-09T09:52:06-08:00
New Revision: 099a62e16ca3a56ee50ff493fb75ff1b119f9c08

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

LOG: [flang] Ensure "dtv" args passed by descriptor when polymorphic

The predicate used to determine whether the initial "dtv" argument
to a user-defined derived type I/O procedure specified by a generic
interface that is not in the derived type definition is wrong.
The "dtv" argument must be passed via a descriptor whenever it is
polymorphic.

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

Added: 
    

Modified: 
    flang/lib/Semantics/runtime-type-info.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/runtime-type-info.cpp b/flang/lib/Semantics/runtime-type-info.cpp
index 153b9841e796..94a1af6bff57 100644
--- a/flang/lib/Semantics/runtime-type-info.cpp
+++ b/flang/lib/Semantics/runtime-type-info.cpp
@@ -1112,15 +1112,18 @@ void RuntimeTableBuilder::DescribeSpecialProc(
       }
     } else { // user defined derived type I/O
       CHECK(proc->dummyArguments.size() >= 4);
+      const auto *ddo{std::get_if<evaluate::characteristics::DummyDataObject>(
+          &proc->dummyArguments[0].u)};
+      if (!ddo) {
+        return;
+      }
       if (derivedTypeSpec &&
-          !std::get<evaluate::characteristics::DummyDataObject>(
-              proc->dummyArguments[0].u)
-               .type.type()
-               .IsTkCompatibleWith(evaluate::DynamicType{*derivedTypeSpec})) {
+          !ddo->type.type().IsTkCompatibleWith(
+              evaluate::DynamicType{*derivedTypeSpec})) {
         // Defined I/O specific procedure is not for this derived type.
         return;
       }
-      if (binding) {
+      if (ddo->type.type().IsPolymorphic()) {
         isArgDescriptorSet |= 1;
       }
       switch (io.value()) {


        


More information about the flang-commits mailing list