Skip to content

Commit ed1a555

Browse files
klauslerjeanPerier
authored andcommitted
[flang] Accept SIZE(assumed-rank, DIM=n)
Silence a bogus error message about an out-of-range DIM= argument when the argument is assumed-rank. (More generally, don't pretend to be able to discern a shape of known rank for an assumed-rank object.) Differential Revision: https://reviews.llvm.org/D109915
1 parent 6e0e075 commit ed1a555

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

flang/lib/Evaluate/shape.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ auto GetShapeHelper::operator()(const Symbol &symbol) const -> Result {
500500
[&](const semantics::ObjectEntityDetails &object) {
501501
if (IsImpliedShape(symbol) && object.init()) {
502502
return (*this)(object.init());
503+
} else if (IsAssumedRank(symbol)) {
504+
return Result{};
503505
} else {
504506
int n{object.shape().Rank()};
505507
NamedEntity base{symbol};
@@ -517,12 +519,12 @@ auto GetShapeHelper::operator()(const Symbol &symbol) const -> Result {
517519
}
518520
},
519521
[&](const semantics::AssocEntityDetails &assoc) {
520-
if (!assoc.rank()) {
521-
return (*this)(assoc.expr());
522-
} else {
522+
if (assoc.rank()) { // SELECT RANK case
523523
int n{assoc.rank().value()};
524524
NamedEntity base{symbol};
525525
return Result{CreateShape(n, base)};
526+
} else {
527+
return (*this)(assoc.expr());
526528
}
527529
},
528530
[&](const semantics::SubprogramDetails &subp) {

0 commit comments

Comments
 (0)