[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
This commit is contained in:
peter klausler 2021-09-13 10:41:27 -07:00
parent 41ff7612b3
commit 12ba727897
1 changed files with 5 additions and 3 deletions

View File

@ -500,6 +500,8 @@ auto GetShapeHelper::operator()(const Symbol &symbol) const -> Result {
[&](const semantics::ObjectEntityDetails &object) {
if (IsImpliedShape(symbol) && object.init()) {
return (*this)(object.init());
} else if (IsAssumedRank(symbol)) {
return Result{};
} else {
int n{object.shape().Rank()};
NamedEntity base{symbol};
@ -517,12 +519,12 @@ auto GetShapeHelper::operator()(const Symbol &symbol) const -> Result {
}
},
[&](const semantics::AssocEntityDetails &assoc) {
if (!assoc.rank()) {
return (*this)(assoc.expr());
} else {
if (assoc.rank()) { // SELECT RANK case
int n{assoc.rank().value()};
NamedEntity base{symbol};
return Result{CreateShape(n, base)};
} else {
return (*this)(assoc.expr());
}
},
[&](const semantics::SubprogramDetails &subp) {