[flang-commits] [flang] [flang][OpenMP] Handle fixed length `charater`s in delayed privatization (PR #126704)

via flang-commits flang-commits at lists.llvm.org
Tue Feb 11 09:01:05 PST 2025


================
@@ -197,12 +197,20 @@ static void getLengthParameters(fir::FirOpBuilder &builder, mlir::Location loc,
   // The verifier for EmboxOp doesn't allow length parameters when the the
   // character already has static LEN. genLengthParameters may still return them
   // in this case.
-  mlir::Type unwrappedType =
-      fir::unwrapRefType(fir::unwrapSeqOrBoxedSeqType(moldArg.getType()));
-  if (auto strTy = mlir::dyn_cast<fir::CharacterType>(unwrappedType)) {
-    if (strTy.hasConstantLen())
-      lenParams.resize(0);
-  }
+  auto strTy = [&]() -> fir::CharacterType {
+    if (auto result = mlir::dyn_cast<fir::CharacterType>(
+            fir::unwrapRefOrBoxedRefType(moldArg.getType())))
+      return result;
+
+    if (auto result = mlir::dyn_cast<fir::CharacterType>(fir::unwrapRefType(
+            fir::unwrapSeqOrBoxedSeqType(moldArg.getType()))))
+      return result;
+
+    return nullptr;
+  }();
----------------
jeanPerier wrote:


```suggestion
auto strTy = mlir::dyn_cast<fir::CharacterType>(fir::unwrapSequenceType(fir::unwrapPassByRefType(fir::unwrapRefType(moldArg.getType()))));
```
      

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


More information about the flang-commits mailing list