[flang-commits] [flang] [flang] Fixed regression in copy-in/copy-out (PR #161259)
via flang-commits
flang-commits at lists.llvm.org
Wed Nov 5 13:28:51 PST 2025
================
@@ -1572,28 +1553,35 @@ class CopyInOutExplicitInterface {
// procedures with explicit interface, it's expected that "dummy" is not null.
// For procedures with implicit interface dummy may be null.
//
+// Returns std::optional<bool> indicating whether the copy is known to be
+// needed (true) or not needed (false); returns std::nullopt if the necessity
+// of the copy is undetermined.
+//
// Note that these copy-in and copy-out checks are done from the caller's
// perspective, meaning that for copy-in the caller need to do the copy
// before calling the callee. Similarly, for copy-out the caller is expected
// to do the copy after the callee returns.
-bool MayNeedCopy(const ActualArgument *actual,
+std::optional<bool> ActualArgNeedsCopy(const ActualArgument *actual,
const characteristics::DummyArgument *dummy, FoldingContext &fc,
bool forCopyOut) {
+ constexpr auto unknown = std::nullopt;
if (!actual) {
- return false;
+ return unknown;
}
if (actual->isAlternateReturn()) {
- return false;
+ return unknown;
}
const auto *dummyObj{dummy
? std::get_if<characteristics::DummyDataObject>(&dummy->u)
: nullptr};
const bool forCopyIn = !forCopyOut;
if (!evaluate::IsVariable(*actual)) {
- // Actual argument expressions that aren’t variables are copy-in, but
- // not copy-out.
+ // Expressions are copy-in, but not copy-out.
return forCopyIn;
}
+ auto maybeContigActual{IsContiguous(*actual, fc)};
+ bool isContiguousActual{
+ maybeContigActual.has_value() && maybeContigActual.value()};
----------------
jeanPerier wrote:
nit: isContiguousActual{IsContiguous(*actual, fc).value_or(false)}';
https://github.com/llvm/llvm-project/pull/161259
More information about the flang-commits
mailing list