[flang] Adjust semantics of the char length of an array constructor (#97337)

An implied DO loop with no trips in an array constructor does not have a
well-defined character length unless its data items have a length that
is constant expression. That works, but the implementation is too
broadly applied. An array constructor with an explicit type-spec always
has a well-defined length.
This commit is contained in:
Peter Klausler
2024-07-11 12:29:58 -07:00
committed by GitHub
parent 7f2a5dfe35
commit 2d7e136fc0
3 changed files with 7 additions and 6 deletions

View File

@@ -1584,7 +1584,8 @@ private:
std::optional<Expr<SubscriptInteger>> LengthIfGood() const {
if (type_) {
auto len{type_->LEN()};
if (len && IsConstantExpr(*len) && !ContainsAnyImpliedDoIndex(*len)) {
if (explicitType_ ||
(len && IsConstantExpr(*len) && !ContainsAnyImpliedDoIndex(*len))) {
return len;
}
}