Skip to content

Commit fddadd2

Browse files
authored
[flang] Address case of under-processed array symbol (#73169)
Array element references are frequently parsed as function references due to the ambiguous syntax of Fortran, and the parse tree is repaired by semantics once the relevant symbol table entries are in hand. This patch fixes a case in which the correction takes a path that leaves the type of a symbol undetermined, leading to later spurious errors in expression analysis. Fixes #68652.
1 parent 33b54f0 commit fddadd2

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

flang/lib/Semantics/resolve-names.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7731,7 +7731,6 @@ void ResolveNamesVisitor::HandleProcedureName(
77317731
} else if (CheckUseError(name)) {
77327732
// error was reported
77337733
} else {
7734-
auto &nonUltimateSymbol{*symbol};
77357734
symbol = &Resolve(name, symbol)->GetUltimate();
77367735
CheckEntryDummyUse(name.source, symbol);
77377736
bool convertedToProcEntity{ConvertToProcEntity(*symbol)};
@@ -7756,9 +7755,7 @@ void ResolveNamesVisitor::HandleProcedureName(
77567755
// is created for the current scope.
77577756
// Operate on non ultimate symbol so that HostAssocDetails are also
77587757
// created for symbols used associated in the host procedure.
7759-
if (IsUplevelReference(nonUltimateSymbol)) {
7760-
MakeHostAssocSymbol(name, nonUltimateSymbol);
7761-
}
7758+
ResolveName(name);
77627759
} else if (symbol->test(Symbol::Flag::Implicit)) {
77637760
Say(name,
77647761
"Use of '%s' as a procedure conflicts with its implicit definition"_err_en_US);

flang/test/Semantics/symbol33.f90

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
! RUN: %python %S/test_symbols.py %s %flang_fc1
2+
! Ensure that a misparsed function reference that turns out to be an
3+
! array element reference still applies implicit typing, &c.
4+
!DEF: /subr (Subroutine) Subprogram
5+
subroutine subr
6+
!DEF: /subr/moo (Implicit) ObjectEntity INTEGER(4)
7+
common //moo(1)
8+
!DEF: /subr/a ObjectEntity REAL(4)
9+
!REF: /subr/moo
10+
real a(moo(1))
11+
end subroutine

0 commit comments

Comments
 (0)