diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp index 2202639a92e43..90900d9acb6ad 100644 --- a/flang/lib/Semantics/expression.cpp +++ b/flang/lib/Semantics/expression.cpp @@ -523,7 +523,7 @@ static std::optional FixMisparsedSubstringDataRef( parser::GetLastName(arrElement.base).symbol}) { const Symbol &ultimate{symbol->GetUltimate()}; if (const semantics::DeclTypeSpec *type{ultimate.GetType()}) { - if (!ultimate.IsObjectArray() && + if (ultimate.Rank() == 0 && type->category() == semantics::DeclTypeSpec::Character) { // The ambiguous S(j:k) was parsed as an array section // reference, but it's now clear that it's a substring.