This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, Fortran] PR 47266: Mark privat module procedures as TREE_PUBLIC=0


On 14/01/2011 7:57 AM, Tobias Burnus wrote:
Module procedures which are marked as PRIVATE do not need to be
available outside of the translation unit - thus they do not need to be
TREE_PUBLIC (unless they are bind(C)).

Private functions that are used in specification expressions for the length of a function result for public functions may need further consideration. For example:


! In mod-with_priv_fun.f90
MODULE mod_with_priv_fun
  IMPLICIT NONE
  PRIVATE
  PUBLIC :: pub_fun
  PRIVATE :: priv_fun
CONTAINS
  FUNCTION pub_fun(arg) RESULT(s)
    INTEGER, INTENT(IN) :: arg
    CHARACTER(LEN=priv_fun(arg)) :: s
    !****
    s = 'ABCDEFGHHIJKLMNOPQRSTUVWXYZ'
  END FUNCTION pub_fun
  PURE FUNCTION priv_fun(arg) RESULT(l)
    INTEGER, INTENT(IN) :: arg
    INTEGER :: l
    !****
    l = arg + 1
  END FUNCTION priv_fun
END MODULE mod_with_priv_fun

! In test_driver.f90
PROGRAM test_driver
  USE mod_with_priv_fun
  IMPLICIT NONE
  CHARACTER(20) :: s
  s = pub_fun(4) // '--'
  PRINT "(A)", s
END PROGRAM test_driver

fails with a link error (undefined symbol __mod_with_priv_fun_MOD_priv_fun) with this patch.

(Note the attribute needs to be explicitly set on the private function to see the link problem.)

PR44265 demonstrates a similar problem (but for parameters) where otherwise "private" symbols need to be visible in the outside world.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]