This is an archive of the discontinued LLVM Phabricator instance.

[flang] Add tests for passing procedure arguments with implicit interfaces
ClosedPublic

Authored by PeteSteinfeld on Jan 12 2021, 9:03 AM.

Details

Summary

It's possible to declare an external procedure with an implicit interface and
then pass it as an actual argument to a subprogram expecting a procedure
argument. I added tests for this and added an error message to distinguish
passing an actual argument with an implicit interface from passing an argument
with a mismatched explicit interface.

Diff Detail

Event Timeline

PeteSteinfeld requested review of this revision.Jan 12 2021, 9:03 AM
PeteSteinfeld created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2021, 9:03 AM
PeteSteinfeld added a project: Restricted Project.Jan 12 2021, 9:04 AM

If a dummy procedure has an explicit interface, the actual procedure must conform to it (15.5.2.9 paragraph 1). Do your changes allow a actual procedure with an implicit interface to be associated with a dummy procedure with an explicit interface?

If a dummy procedure has an explicit interface, the actual procedure must conform to it (15.5.2.9 paragraph 1). Do your changes allow a actual procedure with an implicit interface to be associated with a dummy procedure with an explicit interface?

My changes allow a procedure declared as "external :: func" to be passed to a procedure dummy argument with an explicit interface. This construct is allowed by pgf90, GNU, IBM, Intel, and NAG. I've implemented this by checking "HasExplicitInterface()" on the characteristics of the actual argument.

I'm not sure how to think about all of this. Does the standard require that a compiler reject a program when the compiler cannot verify at compile time if the characteristics are the same? Are these other compilers not properly enforcing the standard?

I'll investigate other ways to declare procedures with implicit interfaces to see if my implementation is too broad.

I changed this update to just add some tests and a new error message.

PeteSteinfeld retitled this revision from [flang] Fix bogus message passing external procedure as an actual argument to [flang] Add tests for passing procedure arguments with implicit interfaces.Jan 13 2021, 4:32 PM
PeteSteinfeld edited the summary of this revision. (Show Details)
klausler accepted this revision.Jan 13 2021, 4:33 PM
klausler added inline comments.
flang/lib/Semantics/check-call.cpp
552

"which is not known to be compatible with" might be better.

This revision is now accepted and ready to land.Jan 13 2021, 4:33 PM
PeteSteinfeld added inline comments.Jan 13 2021, 4:35 PM
flang/lib/Semantics/check-call.cpp
552

Good suggestion. I'll do it.

This revision was landed with ongoing or failed builds.Jan 13 2021, 4:46 PM
This revision was automatically updated to reflect the committed changes.