[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:23:32 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-runtime

Author: None (serge-sans-paille)

<details>
<summary>Changes</summary>

… architecture

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

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


1 Files Affected:

- (modified) flang/runtime/derived.cpp (+17) 


``````````diff
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()};

``````````

</details>


https://github.com/llvm/llvm-project/pull/99465


More information about the flang-commits mailing list