[flang] Don't discard lower bounds of implicit-shape named constants

F18 preserves lower bounds of explicit-shape named constant arrays, but
failed to also do so for implicit-shape named constants.  Fix.

Differential Revision: https://reviews.llvm.org/D127021
This commit is contained in:
Peter Klausler 2022-05-30 16:27:49 -07:00
parent f3278e0f3c
commit 08c6a32381
1 changed files with 4 additions and 1 deletions

View File

@ -418,7 +418,10 @@ std::optional<Expr<SomeType>> NonPointerInitializationExpr(const Symbol &symbol,
int symRank{GetRank(symTS->shape())};
if (IsImpliedShape(symbol)) {
if (folded.Rank() == symRank) {
return {std::move(folded)};
return ArrayConstantBoundChanger{
std::move(*AsConstantExtents(
context, GetRawLowerBounds(context, NamedEntity{symbol})))}
.ChangeLbounds(std::move(folded));
} else {
context.messages().Say(
"Implied-shape parameter '%s' has rank %d but its initializer has rank %d"_err_en_US,