[flang-commits] [flang] [flang] OPTIONAL char dummy has no defining op; add null check (PR #182582)

via flang-commits flang-commits at lists.llvm.org
Fri Feb 20 12:10:19 PST 2026


================
@@ -319,7 +319,10 @@ struct AllocaOpConversion : public fir::FIROpConversion<fir::AllocaOp> {
     unsigned allocaAs = getAllocaAddressSpace(rewriter);
     unsigned programAs = getProgramAddressSpace(rewriter);
 
-    if (mlir::isa<mlir::LLVM::ConstantOp>(size.getDefiningOp())) {
+    // A value defined by a block arg, such as fir.if for a
+    // optional assumed character dummy len, doesn't have a defining op.
+    if (auto *defOp = size.getDefiningOp();
+        defOp && mlir::isa<mlir::LLVM::ConstantOp>(size.getDefiningOp())) {
----------------
tmjbios wrote:

Thanks. Suggestion applied.

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


More information about the flang-commits mailing list