Skip to content

Commit e54a8d2

Browse files
Code review feedback
1 parent 6284e57 commit e54a8d2

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

flang/include/flang/Evaluate/call.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ class ActualArgument {
110110

111111
std::optional<DynamicType> GetType() const;
112112
int Rank() const;
113-
bool IsArray() const;
114113
bool operator==(const ActualArgument &) const;
115114
llvm::raw_ostream &AsFortran(llvm::raw_ostream &) const;
116115

flang/include/flang/Evaluate/check-expression.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ std::optional<parser::Message> CheckStatementFunction(
164164
const Symbol &, const Expr<SomeType> &, FoldingContext &);
165165

166166
bool MayNeedCopy(const ActualArgument *, const characteristics::DummyArgument *,
167-
FoldingContext &, bool);
167+
FoldingContext &, bool forCopyOut);
168168

169169
} // namespace Fortran::evaluate
170170
#endif

flang/lib/Evaluate/call.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ int ActualArgument::Rank() const {
5656
}
5757
}
5858

59-
bool ActualArgument::IsArray() const {
60-
return semantics::IsAssumedRank(*this) || Rank() > 0;
61-
}
62-
6359
bool ActualArgument::operator==(const ActualArgument &that) const {
6460
return keyword_ == that.keyword_ && attrs_ == that.attrs_ && u_ == that.u_;
6561
}

flang/lib/Evaluate/check-expression.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,7 +1446,7 @@ std::optional<parser::Message> CheckStatementFunction(
14461446
return StmtFunctionChecker{sf, context}(expr);
14471447
}
14481448

1449-
// Helper class for cheching differences between actual and dummy arguments
1449+
// Helper class for checking differences between actual and dummy arguments
14501450
class CopyInOutExplicitInterface {
14511451
public:
14521452
explicit CopyInOutExplicitInterface(FoldingContext &fc,
@@ -1477,10 +1477,7 @@ class CopyInOutExplicitInterface {
14771477
(dummyTreatAsArray && !dummyIsPolymorphic) || dummyIsVoidStar ||
14781478
dummyObj_.attrs.test(
14791479
characteristics::DummyDataObject::Attr::Contiguous)};
1480-
if (!actualTreatAsContiguous && dummyNeedsContiguity) {
1481-
return true;
1482-
}
1483-
return false;
1480+
return !actualTreatAsContiguous && dummyNeedsContiguity;
14841481
}
14851482

14861483
// Returns true, if actual and dummy have polymorphic differences
@@ -1513,9 +1510,10 @@ class CopyInOutExplicitInterface {
15131510
return false;
15141511
}
15151512

1516-
bool HaveArrayArgs() const {
1513+
bool HaveArrayOrAssumedRankArgs() const {
15171514
bool dummyTreatAsArray{dummyObj_.ignoreTKR.test(common::IgnoreTKR::Rank)};
1518-
return actual_.IsArray() && (dummyObj_.IsArray() || dummyTreatAsArray);
1515+
return IsArrayOrAssumedRank(actual_) &&
1516+
(IsArrayOrAssumedRank(dummyObj_) || dummyTreatAsArray);
15191517
}
15201518

15211519
bool PassByValue() const {
@@ -1530,6 +1528,15 @@ class CopyInOutExplicitInterface {
15301528

15311529
bool HasIntentIn() const { return dummyObj_.intent == common::Intent::In; }
15321530

1531+
static bool IsArrayOrAssumedRank(const ActualArgument &actual) {
1532+
return semantics::IsAssumedRank(actual) || actual.Rank() > 0;
1533+
}
1534+
1535+
static bool IsArrayOrAssumedRank(const characteristics::DummyDataObject &dummy) {
1536+
return dummy.type.attrs().test(characteristics::TypeAndShape::Attr::AssumedRank) ||
1537+
dummy.type.Rank() > 0;
1538+
}
1539+
15331540
private:
15341541
FoldingContext &fc_;
15351542
const ActualArgument &actual_;
@@ -1556,8 +1563,9 @@ static bool MayNeedCopyIn(FoldingContext &fc, const ActualArgument &actual,
15561563
if (check.HaveCoarrayDifferences()) {
15571564
return true;
15581565
}
1559-
// Note: contiguity and polymorphic checks deal with array arguments
1560-
if (!check.HaveArrayArgs()) {
1566+
// Note: contiguity and polymorphic checks deal with array or assumed rank
1567+
// arguments
1568+
if (!check.HaveArrayOrAssumedRankArgs()) {
15611569
return false;
15621570
}
15631571
if (check.HaveContiguityDifferences()) {
@@ -1600,8 +1608,9 @@ static bool MayNeedCopyOut(FoldingContext &fc, const ActualArgument &actual,
16001608
if (check.HaveCoarrayDifferences()) {
16011609
return true;
16021610
}
1603-
// Note: contiguity and polymorphic checks deal with array arguments
1604-
if (!check.HaveArrayArgs()) {
1611+
// Note: contiguity and polymorphic checks deal with array or assumed rank
1612+
// arguments
1613+
if (!check.HaveArrayOrAssumedRankArgs()) {
16051614
return false;
16061615
}
16071616
if (check.HaveContiguityDifferences()) {

0 commit comments

Comments
 (0)