[flang-commits] [flang] [Flang][Runtime] Fix implicit conversion warning when targeting 32bit… (PR #99465)

via flang-commits flang-commits at lists.llvm.org
Thu Jul 18 03:22:59 PDT 2024


https://github.com/serge-sans-paille created https://github.com/llvm/llvm-project/pull/99465

… architecture

On 32 bit systems, TypeParameterValue is 64bit wide while CFI_index_t is 32bit wide.

>From 1f84a53efc431136049420c02bc5d4bdcd280f72 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton at mozilla.com>
Date: Thu, 18 Jul 2024 12:20:17 +0200
Subject: [PATCH] [Flang][Runtime] Fix implicit conversion warning when
 targeting 32bit architecture

On 32 bit systems, TypeParameterValue is 64bit wide while CFI_index_t
is 32bit wide.
---
 flang/runtime/derived.cpp | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/flang/runtime/derived.cpp b/flang/runtime/derived.cpp
index 0d9e033df4e27..e14aa2e927bde 100644
--- a/flang/runtime/derived.cpp
+++ b/flang/runtime/derived.cpp
@@ -90,8 +90,25 @@ RT_API_ATTRS int Initialize(const Descriptor &instance,
         comp.derivedType() && !comp.derivedType()->noInitializationNeeded()) {
       // Default initialization of non-pointer non-allocatable/automatic
       // data component.  Handles parent component's elements.  Recursive.
+<<<<<<< Updated upstream
       SubscriptValue extents[maxRank];
       GetComponentExtents(extents, comp, instance);
+=======
+      SubscriptValue extent[maxRank];
+      const typeInfo::Value *bounds{comp.bounds()};
+      for (int dim{0}; dim < comp.rank(); ++dim) {
+        auto lb = bounds[2 * dim].GetValue(&instance).value_or(0);
+        auto ub = bounds[2 * dim + 1].GetValue(&instance).value_or(0);
+        if (ub >= lb) {
+          auto bound_diff = ub - lb;
+          assert(bound_diff <= std::numeric_limits<SubscriptValue>::max() &&
+              "array bound overflow");
+          extent[dim] = bound_diff;
+        } else {
+          extent[dim] = 0;
+        }
+      }
+>>>>>>> Stashed changes
       StaticDescriptor<maxRank, true, 0> staticDescriptor;
       Descriptor &compDesc{staticDescriptor.descriptor()};
       const typeInfo::DerivedType &compType{*comp.derivedType()};



More information about the flang-commits mailing list