Silverfrost Forums

Welcome to our forums

Derived type definition and private attribute

12 Dec 2018 11:40 #22990

Is this a bug? Should the private declaration in the header of the module def, prevent the main program from finding the definition of the type test_t?

module def
implicit none

private

type test_t
  integer x
end type test_t

end module def


program main
use def
implicit none
type(test_t) :: a

  a%x = 1
  print *,a%x
  
end program main

Or an explicit private applied to the type definition:-

module def
implicit none

private

type, private :: test_t
  integer x
end type test_t

end module def


program main
use def
implicit none
type(test_t) :: a

  a%x = 1
  print *,a%x
  
end program main

In both of the above cases the private declaration(s) have no impact. FTN95 seems to differ from other compiliers on this one.

Ken

13 Dec 2018 11:15 #22996

Ken

I think you are right and I have added code to fix this for the next version of FTN95 after 8.40.

15 Dec 2018 12:09 #23009

Thanks Paul,

Another one for you to consider. This compiles with no errors, which I think is wrong since mod_b should have no access to the definition of z_t.

module a_mod
implicit none

  type xy_t
    integer x, y    
  end type xy_t

  type z_t
    integer z
  end type z_t

end module a_mod


module b_mod
use a_mod, only : xy_t
implicit none

type(z_t) something(1:10)  !FTN95 ignores the only directive

end module b_mod
15 Dec 2018 2:03 #23011

Thanks Ken. I have logged this for investigation.

31 Dec 2018 7:43 #23053

This one has now been fixed for the next release of FTN95.

Please login to reply.