[flang-commits] [flang] [llvm] [flang][MIF] Adding lowering for EVENT POST/WAIT statements (PR #210283)

via flang-commits flang-commits at lists.llvm.org
Wed Oct 21 19:02:49 PDT 2026


================
@@ -297,7 +297,8 @@ struct TypeBuilderImpl {
     if (Fortran::semantics::IsPointer(symbol))
       return fir::wrapInClassOrBoxType(fir::PointerType::get(ty), isPolymorphic,
                                        isAssumedType, symbol.Corank());
-    if (Fortran::semantics::IsAllocatable(symbol))
+    if (Fortran::semantics::IsAllocatable(symbol) ||
+        Fortran::evaluate::IsCoarray(symbol))
----------------
MattPD wrote:

Thanks! With 1d027b1c, my earlier example now prints `[x   ][x   ]`.

The Flang runtime still frees the storage of a VOLATILE coarray, though. Built with `flang -fcoarray` and run on one image, this program aborts with `free(): double free detected in tcache 2`. Before this PR, it printed `[yy  ][yy  ]`:

```fortran
subroutine s()
  character(4), volatile, save :: c(2)[*]
  c = "x"
  c = "yy"
  print *, "[", c(1), "][", c(2), "]"
end subroutine

program p
  call s()
end program
```

`updateTypeWithVolatility` in `FIRType.cpp` rebuilds the box type without its corank, so the new check `fir::getBoxCorank(lhs.getType()) > 0` in `AssignOpConversion` is false for this variable.

Together with the `lhsExv.getBoxOf<fir::BoxValue>()` check from my comment on `ConvertToFIR.cpp`, passing `ty.getCorank()` to `TYPE::get` for `fir::BoxType` and `fir::ClassType` makes this program print `[yy  ][yy  ]` in my local build.

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


More information about the flang-commits mailing list