Skip to content

Commit

Permalink
[flang] Don't discard lower bounds of implicit-shape named constants
Browse files Browse the repository at this point in the history
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
  • Loading branch information
klausler committed Jun 4, 2022
1 parent f3278e0 commit 08c6a32
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion flang/lib/Evaluate/check-expression.cpp
Expand Up @@ -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,
Expand Down

0 comments on commit 08c6a32

Please sign in to comment.