[flang-commits] [flang] [flang] Disable copy-out to INTENT(IN) args (PR #192382)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Thu Apr 16 11:11:18 PDT 2026
================
@@ -1649,6 +1649,17 @@ std::optional<bool> ActualArgNeedsCopy(const ActualArgument *actual,
// Expressions are copy-in, but not copy-out.
return forCopyIn;
}
+ if (forCopyOut) {
+ // If the actual argument's base object has INTENT(IN) in the caller's
+ // context, copy-out would violate the read-only semantics of INTENT(IN).
+ if (const Expr<SomeType> *expr{actual->UnwrapExpr()}) {
+ if (const Symbol *symbol{GetFirstSymbol(*expr)}) {
----------------
eugeneepshteyn wrote:
Yes, very good point. Also I think for `integer, intent(in), pointer :: pi(:)`, the intent "guards" pointer association, not the values.
Also, a few Fujitsu tests failed, including [0070_0001](https://github.com/fujitsu/compiler-test-suite/blob/main/Fortran/0070/0070_0001.f90), which is similar to your example. Need to make the checks more targeted.
https://github.com/llvm/llvm-project/pull/192382
More information about the flang-commits
mailing list