Skip to content

Commit eb9a78b

Browse files
authored
[flang] Fix bad parse tree rewrite into a substring (#98407)
Data designators like "a(j:k)" are parsed into array section references, but once rank and type information is in hand, some of them turn out to actually be substring references. The code that recognizes these cases was suffering from a "false positive" in the case of a construct entity in a SELECT RANK construct due to the use of a predicate member function (Symbol::IsObjectArray) that only works on ObjectEntityDetails symbols. Fix the test to use the more general Symbol::Rank() member function.
1 parent a074f88 commit eb9a78b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

flang/lib/Semantics/expression.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ static std::optional<parser::Substring> FixMisparsedSubstringDataRef(
523523
parser::GetLastName(arrElement.base).symbol}) {
524524
const Symbol &ultimate{symbol->GetUltimate()};
525525
if (const semantics::DeclTypeSpec *type{ultimate.GetType()}) {
526-
if (!ultimate.IsObjectArray() &&
526+
if (ultimate.Rank() == 0 &&
527527
type->category() == semantics::DeclTypeSpec::Character) {
528528
// The ambiguous S(j:k) was parsed as an array section
529529
// reference, but it's now clear that it's a substring.

0 commit comments

Comments
 (0)