This is an archive of the discontinued LLVM Phabricator instance.

[flang] Fix combining cases of USE association & generic interfaces
ClosedPublic

Authored by klausler on Apr 13 2022, 12:17 PM.

Details

Summary

Fortran admits a few ways to have multiple symbols with the
same name in the same scope. Two of them involve generic
interfaces (from INTERFACE or GENERIC, the syntax doesn't matter);
these are allowed to inhabit a scope with either a derived type or
a subprogram that is also a specific procedure of the generic.
(But not both a derived type and a subprogram; they could not
cohabit a scope anyway, generic or not.)

In cases of USE association, f18 needs to be capable of combining
use-associated generic interfaces with other use-associated entities.
Two generics get merged (this case was nearly correct); a generic
and a derived type can merge into a GenericDetails with a shadowed
derivedType(); and a generic can replace or ignore a use-associated
procedure of the same name so long as that procedure is already
one of its specifics.

Further, these modifications to the use-associated generic
interface must be made to a local copy of the symbol. The previous
code was messing directly with the symbol in the module's scope.

The fix is basically a reimplementation of the member function
DoAddUse() in name resolution.

Diff Detail

Event Timeline

klausler created this revision.Apr 13 2022, 12:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2022, 12:17 PM
Herald added a subscriber: jdoerfert. · View Herald Transcript
klausler requested review of this revision.Apr 13 2022, 12:17 PM
This revision is now accepted and ready to land.Apr 14 2022, 2:14 AM