[flang-commits] [flang] 82cb792 - [flang][runtime] Allow CLASS(*) components when creating descriptors

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Fri Dec 16 15:09:49 PST 2022


Author: Peter Klausler
Date: 2022-12-16T15:09:37-08:00
New Revision: 82cb792066e1476f5ce41a2dfe719617e80c67ec

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

LOG: [flang][runtime] Allow CLASS(*) components when creating descriptors

Extend the descriptor creation function for components to allow
unlimited polymorphic components (CLASS(*)) and to also properly set
the attributes of the established descriptors.

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

Added: 
    

Modified: 
    flang/runtime/type-info.cpp

Removed: 
    


################################################################################
diff  --git a/flang/runtime/type-info.cpp b/flang/runtime/type-info.cpp
index ecc2bf9e28d91..84ec05d02705f 100644
--- a/flang/runtime/type-info.cpp
+++ b/flang/runtime/type-info.cpp
@@ -87,6 +87,10 @@ std::size_t Component::SizeInBytes(const Descriptor &instance) const {
 
 void Component::EstablishDescriptor(Descriptor &descriptor,
     const Descriptor &container, Terminator &terminator) const {
+  ISO::CFI_attribute_t attribute{static_cast<ISO::CFI_attribute_t>(
+      genre_ == Genre::Allocatable   ? CFI_attribute_allocatable
+          : genre_ == Genre::Pointer ? CFI_attribute_pointer
+                                     : CFI_attribute_other)};
   TypeCategory cat{category()};
   if (cat == TypeCategory::Character) {
     std::size_t lengthInChars{0};
@@ -96,13 +100,17 @@ void Component::EstablishDescriptor(Descriptor &descriptor,
       RUNTIME_CHECK(
           terminator, characterLen_.genre() == Value::Genre::Deferred);
     }
-    descriptor.Establish(kind_, lengthInChars, nullptr, rank_);
+    descriptor.Establish(
+        kind_, lengthInChars, nullptr, rank_, nullptr, attribute);
   } else if (cat == TypeCategory::Derived) {
-    const DerivedType *type{derivedType()};
-    RUNTIME_CHECK(terminator, type != nullptr);
-    descriptor.Establish(*type, nullptr, rank_);
+    if (const DerivedType * type{derivedType()}) {
+      descriptor.Establish(*type, nullptr, rank_, nullptr, attribute);
+    } else { // unlimited polymorphic
+      descriptor.Establish(TypeCode{TypeCategory::Derived, 0}, 0, nullptr,
+          rank_, nullptr, attribute, true);
+    }
   } else {
-    descriptor.Establish(cat, kind_, nullptr, rank_);
+    descriptor.Establish(cat, kind_, nullptr, rank_, nullptr, attribute);
   }
   if (rank_ && genre_ != Genre::Allocatable) {
     const typeInfo::Value *boundValues{bounds()};


        


More information about the flang-commits mailing list