This is an archive of the discontinued LLVM Phabricator instance.

[flang] Handle instantiation of procedure pointer components
ClosedPublic

Authored by PeteSteinfeld on Apr 12 2021, 1:12 PM.

Details

Summary

We were not instantiating procedure pointer components. If the instantiation
contained errors, we were not reporting them. This resulted in internal errors
in later processing.

I fixed this by adding code in .../lib/Semantics/type.cpp in
InstantiateComponent() to handle a component with ProcEntityDetails. I also
added several tests for various good and bad instantiations of procedure
pointer components.

One of the tests caused a redundant context message to appear. I fixed this by
removing a call to set_instantiationContext() from
DerivedTypeSpec::Instantiate().

Diff Detail

Event Timeline

PeteSteinfeld requested review of this revision.Apr 12 2021, 1:12 PM
PeteSteinfeld created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2021, 1:12 PM
PeteSteinfeld added a project: Restricted Project.Apr 12 2021, 1:13 PM
klausler added inline comments.Apr 12 2021, 2:37 PM
flang/lib/Semantics/type.cpp
310

Why is the scope's instantiation context no longer needing to be set? Are you somehow setting it elsewhere?

378

Are you sure that you're modifying a new ProcInterface created for this procedure pointer component's instantiation, or are you maybe modifying a ProcInterface shared by all instantiation?

PeteSteinfeld added inline comments.Apr 13 2021, 10:19 AM
flang/lib/Semantics/type.cpp
310

My mistake. I'll put this back.

378

When I look at the symbol table dump for a test program, I see an unmodified entry for the original derived type definition and modified entries for the instantiations. Correct me if I'm wrong, but that says that I'm not modifying the version that's shared by all instantiations. Note that the testExtended() subroutine in resolve105.f90 contains alternating good and band instantiations, and error messages are only produced by the bad instantiations.

Here's a fragment of a symbol table dump of a small test:

MainProgram scope: test size=0 alignment=1
  base: DerivedType components: field
  dependenttype: DerivedType components: dependentfield
  null, INTRINSIC, PURE (Function): ProcEntity
  testdependent (Subroutine): Subprogram ()
  DerivedType scope: base
    field, NOPASS, POINTER (Function): ProcEntity REAL(int(int(kindparam,kind=4),kind=8)) => NULL()
    kindparam: TypeParam type:INTEGER(4) Kind init:4_4
  DerivedType scope: dependenttype
    dependentfield, NOPASS, POINTER (Function): ProcEntity TYPE(base(kindparam=int(kindparam,kind=4))) => NULL()
    kindparam: TypeParam type:INTEGER(4) Kind init:4_4
  Subprogram scope: testdependent size=24 alignment=8
    local size=24 offset=0: ObjectEntity type: TYPE(dependenttype(kindparam=77_4))
    testdependent (Subroutine): HostAssoc
    DerivedType scope: size=24 alignment=8 instantiation of dependenttype(kindparam=77_4)
      dependentfield, NOPASS, POINTER (Function) size=24 offset=0: ProcEntity TYPE(base(kindparam=77_4))
      kindparam: TypeParam type:INTEGER(4) Kind init:77_4
      DerivedType scope: size=24 alignment=8 instantiation of base(kindparam=77_4)
        field, NOPASS, POINTER (Function) size=24 offset=0: ProcEntity REAL(4)
        kindparam: TypeParam type:INTEGER(4) Kind init:77_4
klausler accepted this revision.Apr 13 2021, 10:29 AM
This revision is now accepted and ready to land.Apr 13 2021, 10:29 AM

Responding to Peter's feedback by restoring the call to set_instantitationContext().

This revision was landed with ongoing or failed builds.Apr 13 2021, 10:56 AM
This revision was automatically updated to reflect the committed changes.