Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call-graph ramifications of the FORD type-bound procedures public/private policy #538

Closed
patflynngithub opened this issue Jul 7, 2023 · 2 comments · Fixed by #539
Closed
Labels

Comments

@patflynngithub
Copy link

The FORD type-bound procedures public/private policy (discussed a bit here in issue #508) has ramifications for call-graph display of type-bound procedures.

First some example code:

program main
  
  use a_module
  implicit none
  
  type(a_module_t)  :: a_module_t_obj
  call a_module_t_obj%a_module_t_sub("There")

end program main
! ---------------------------
module a_module

implicit none
private

public :: a_module_t
! public :: a_module_t_sub  ! THIS IS THE STATEMENT THAT ALLOWS THE TYPE-BOUND PROCEDURE
                            !  TO BE DISPLAYED IN THE CALL-GRAPH

  type a_module_t
    private
    integer :: a_module_t_int
  contains
    procedure :: a_module_t_sub
  end type a_module_t

contains

subroutine a_module_t_sub(this, output)
    implicit none
    
    class(a_module_t), intent(in) :: this
    character(len=*), intent(in)  :: output   !! character(len=*), intent(in) :: output

     write(*,*) "a_module_t_sub: ", output
 end subroutine a_module_t_sub

end module a_module

When graphs are generated for this code, the publicly accessible type-bound procedure a_module_t_sub() is not displayed in the main program's call graph. In fact, because the program only has the type-bound procedure call, no call-graph is generated at all for the program. If there were other procedure calls in the program that FORD considers "fully" public, then the call-graph would be generated (minus the non fully public type-bound procedure).

The solution to this is the same as getting the type-bound procedures to be listed on the FORD Procedures main page list and the Procedures webpage. Add

public :: a_module_t_sub

at the module level of a_module (commented in above code).

So, as with the display of type-bound procedures in the FORD Procedures list and webpage, we are forced to modify our Fortran code just to get FORD to document it in a way that it seems FORD should be able do without the code change.

@patflynngithub
Copy link
Author

@ZedThree
A further wrinkle in this issue is when there is a binding name (i.e. sub in this case) added to the type-bound procedure from the above orginal code example:

  type a_module_t
    private
    integer :: a_module_t_int
  contains
    procedure :: sub => a_module_t_sub
  end type a_module_t

along with a main program call to the binding name

call a_module_t_obj%sub("There")

Regardless if there is a public :: a_module_t_sub statement and there is no module-level private statement, this call does not appear in the program's call-graph (the call-graph is not even generated in this case because it's the only procedure call).

@ZedThree
Copy link
Member

This is at least partially fixed in #539. "Called-by" graphs are not yet generated for type-bound procedures, I will look into fixing that when I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants