This is an archive of the discontinued LLVM Phabricator instance.

[flang] Correct disambiguation of possible statement function definitions
ClosedPublic

Authored by klausler on Jul 17 2023, 10:20 AM.

Details

Summary

The statement "A(J) = expr" could be an assignment to an element of an
array A, an assignment to the target of a pointer-valued function A, or
the definition of a new statement function in the local scope named A,
depending on whether it appears in (what might still be) the specification
part of a program or subprogram and what other declarations and definitions
for A might exist in the local scope or have been imported into it.

The standard requires that the name of a statement function appear in
an earlier type declaration statement if it is also the name of an
entity in the enclosing scope. Some other Fortran compilers mistakenly
enforce that rule in the case of an assignment to the target of a
pointer-valued function in the containing scope, after misinterpreting
the assignment as a new local statement function definition.

This patch cleans up the handling of the various possibilities and
resolves what was a crash in the case of a statement function definition
whose name was the same as that of a procedure in the outer scope whose
result is *not* a pointer.

Diff Detail

Event Timeline

klausler created this revision.Jul 17 2023, 10:20 AM
Herald added a project: Restricted Project. · View Herald Transcript
klausler requested review of this revision.Jul 17 2023, 10:20 AM
PeteSteinfeld accepted this revision.Jul 17 2023, 11:40 AM

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.Jul 17 2023, 11:40 AM
This revision was landed with ongoing or failed builds.Jul 17 2023, 12:34 PM
This revision was automatically updated to reflect the committed changes.