[flang-commits] [flang] [Flang][OpenMP] Fix crash with character types in declare_reduction (PR #178038)

Krish Gupta via flang-commits flang-commits at lists.llvm.org
Wed Jan 28 03:21:04 PST 2026


================
@@ -408,14 +408,17 @@ bool ClauseProcessor::processInitializer(
             Fortran::lower::translateSymbolAttributes(
                 builder.getContext(), *object.sym(), extraFlags);
         std::string name = object.sym()->name().ToString();
-        // For character types, we need to provide the length parameter
+        // Get length parameters for types that need them (e.g., characters)
         llvm::SmallVector<mlir::Value> typeParams;
-        mlir::Type unwrappedType = fir::unwrapRefType(ompOrigType);
-        if (auto charTy = mlir::dyn_cast<fir::CharacterType>(unwrappedType)) {
-          if (charTy.hasConstantLen()) {
-            mlir::Value lenValue = builder.createIntegerConstant(
-                loc, builder.getIndexType(), charTy.getLen());
-            typeParams.push_back(lenValue);
+        if (hlfir::isFortranEntity(addr)) {
+          hlfir::genLengthParameters(loc, builder, hlfir::Entity{addr},
----------------
KrxGu wrote:

done!!

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


More information about the flang-commits mailing list