[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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user