Skip to content

Commit

Permalink
[flang] Address case of under-processed array symbol (#73169)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
klausler committed Nov 30, 2023
1 parent 33b54f0 commit fddadd2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 1 addition & 4 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7731,7 +7731,6 @@ void ResolveNamesVisitor::HandleProcedureName(
} else if (CheckUseError(name)) {
// error was reported
} else {
auto &nonUltimateSymbol{*symbol};
symbol = &Resolve(name, symbol)->GetUltimate();
CheckEntryDummyUse(name.source, symbol);
bool convertedToProcEntity{ConvertToProcEntity(*symbol)};
Expand All @@ -7756,9 +7755,7 @@ void ResolveNamesVisitor::HandleProcedureName(
// is created for the current scope.
// Operate on non ultimate symbol so that HostAssocDetails are also
// created for symbols used associated in the host procedure.
if (IsUplevelReference(nonUltimateSymbol)) {
MakeHostAssocSymbol(name, nonUltimateSymbol);
}
ResolveName(name);
} else if (symbol->test(Symbol::Flag::Implicit)) {
Say(name,
"Use of '%s' as a procedure conflicts with its implicit definition"_err_en_US);
Expand Down
11 changes: 11 additions & 0 deletions flang/test/Semantics/symbol33.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
! RUN: %python %S/test_symbols.py %s %flang_fc1
! Ensure that a misparsed function reference that turns out to be an
! array element reference still applies implicit typing, &c.
!DEF: /subr (Subroutine) Subprogram
subroutine subr
!DEF: /subr/moo (Implicit) ObjectEntity INTEGER(4)
common //moo(1)
!DEF: /subr/a ObjectEntity REAL(4)
!REF: /subr/moo
real a(moo(1))
end subroutine

0 comments on commit fddadd2

Please sign in to comment.