This is an archive of the discontinued LLVM Phabricator instance.

[flang] Better error handling and testing of generics with homonymous specifics or derived types
ClosedPublic

Authored by klausler on May 18 2023, 3:38 PM.

Details

Summary

Fortran allows a generic procedure interface to have the same name as a derived
type in the same scope or the same name as one of its specific procedures.
(It can't have both since a derived type and specific procedure can't have the
same name in a scope.)

Some popular compilers allow generic interfaces with distinct accessible homonymous
specific procedures to be merged by USE association. Thsi compiler does not,
and for good reason: it leads to ambiguity in cases where a procedure name appears
outside a reference, such as in a PROCEDURE declaration statement as the procedure's
interface, the target of a procedure pointer assignment statement, or as an
actual argument.

This patch cleans up the code that handles these cases, improves some error
messages, and adds more tests.

Resolves https://github.com/llvm/llvm-project/issues/60228.

Diff Detail

Event Timeline

klausler created this revision.May 18 2023, 3:38 PM
Herald added a project: Restricted Project. · View Herald Transcript
klausler requested review of this revision.May 18 2023, 3:38 PM
klausler updated this revision to Diff 523589.May 18 2023, 3:45 PM

Fix test included in patch.

PeteSteinfeld accepted this revision.May 18 2023, 5:10 PM

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.May 18 2023, 5:10 PM

Further investigation shows that this is not actually valid Fortran usage. Will replace with better error messages and tests.

klausler updated this revision to Diff 524312.May 22 2023, 7:53 AM
klausler retitled this revision from [flang] Fix handling of USE association of generics with homonymous specifics to [flang] Better error handling and testing of generics with homonymous specifics or derived types.
klausler edited the summary of this revision. (Show Details)

Previous patch was wrong, as was the bug report. This usage is not good Fortran. Improve error messages and tests.