Skip to content

Commit 889d514

Browse files
In DetermineCopyInOutArgument(), handle INTENT(IN) and INTENT(OUT)
1 parent 3ec01ad commit 889d514

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

flang/lib/Evaluate/call.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,28 @@ static void DetermineCopyInOutArgument(
286286
// Only DummyDataObject has the information we need
287287
return;
288288
}
289-
289+
// Pass by value, always copy-in, never copy-out
290290
bool dummyIsValue{
291291
dummyObj->attrs.test(characteristics::DummyDataObject::Attr::Value)};
292292
if (dummyIsValue) {
293293
actual.SetMayNeedCopyIn();
294294
return;
295295
}
296+
bool dummyIntentIn{dummyObj->intent == common::Intent::In};
297+
bool dummyIntentOut{dummyObj->intent == common::Intent::Out};
298+
299+
auto setCopyIn = [&]() {
300+
if (!dummyIntentOut) {
301+
// INTENT(OUT) never need copy-in
302+
actual.SetMayNeedCopyIn();
303+
}
304+
};
305+
auto setCopyOut = [&]() {
306+
if (!dummyIntentIn) {
307+
// INTENT(IN) never need copy-out
308+
actual.SetMayNeedCopyOut();
309+
}
310+
};
296311

297312
// Check actual contiguity, unless dummy doesn't care
298313
bool actualTreatAsContiguous{
@@ -312,12 +327,15 @@ static void DetermineCopyInOutArgument(
312327
dummyObj->attrs.test(
313328
characteristics::DummyDataObject::Attr::Contiguous))};
314329
if (!actualTreatAsContiguous && dummyNeedsContiguity) {
315-
actual.SetMayNeedCopyIn();
330+
setCopyIn();
316331
if (!actualHasVectorSubscript) {
317-
actual.SetMayNeedCopyOut();
332+
setCopyOut();
318333
}
334+
return;
319335
}
320336

337+
// TODO: passing polymorphic to non-polymorphic
338+
321339
// TODO
322340
}
323341

0 commit comments

Comments
 (0)