This is an archive of the discontinued LLVM Phabricator instance.

[flang] Allow mixed association of procedure pointers and targets
ClosedPublic

Authored by PeteSteinfeld on Feb 9 2022, 7:47 PM.

Details

Summary

Section 10.2.2.4, paragraph 3 states that a procedure pointer with an explicit
interface must have the same characteristics as its target. Previously, we
interpreted this as disallowing such pointers to point to procedures with
implicit interfaces. But several other compilers allow this.

This change makes us allow this, also.

Diff Detail

Event Timeline

PeteSteinfeld created this revision.Feb 9 2022, 7:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 9 2022, 7:47 PM
PeteSteinfeld requested review of this revision.Feb 9 2022, 7:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 9 2022, 7:47 PM
PeteSteinfeld edited the summary of this revision. (Show Details)Feb 9 2022, 7:49 PM
PeteSteinfeld added reviewers: jeanPerier, klausler.
jeanPerier added inline comments.Feb 10 2022, 12:27 AM
flang/lib/Evaluate/tools.cpp
977

I agree that nag/gfortran/ifort/nvfortran do not complain if the pointer explicit interface is compatible with an implicit interface (CanBeCalledViaImplicitInterface()), but it seems only nvfortran allows the cases where the explicit interface cannot be called via implicit interface. The following program is refused by nag/ifort/gfortran/xlf (and I think we should too, unless they are programs that really needs it):

module m
    interface
      subroutine requires_explicit_iface(p)
        real, pointer :: p(:)
      end subroutine
    end interface
contains
subroutine test
  procedure(requires_explicit_iface), pointer :: p
    external :: s_external
    p => s_external
end subroutine
end module

So you could still complain here if !lhsProcedure->CanBeCalledViaImplicitInterface() IMHO.

Agree with Jean's comment.

PeteSteinfeld added inline comments.Feb 10 2022, 12:35 PM
flang/lib/Evaluate/tools.cpp
977

Thanks, Jean. That makes sense.

I'll add some code and a test.

Responding to Jean's comments.

@jeanPerier or @klausler, can you please take another look?

klausler accepted this revision.Feb 11 2022, 9:18 AM
This revision is now accepted and ready to land.Feb 11 2022, 9:18 AM
This revision was landed with ongoing or failed builds.Feb 11 2022, 10:56 AM
This revision was automatically updated to reflect the committed changes.