According to the Standard, this is prohibited. The component attribute specifier can only be pointer and dimension for Fortran 90/95 (section 4.4.1), additionally allocatable in Fortran 2003 (section 4.5.3), as well as codimension and contiguous for Fortran 2008 (section 4.5.4.1).
You can get the documents here .
I ran into a similar problem with the target specifier, which is also not resolved.
EDIT: Why not try private components?
module typedef type :: my_type integer, private :: a_int = 1 real(kind(1.d0)) :: b contains procedure :: a end type my_type contains function a(complex_type) class(my_type),intent(in) :: complex_type integer :: a a = complex_type%a_int end function end module program my_prog use typedef implicit none type (my_type) :: complex_type complex_type%b = 2.d0 ! This should work write(*,*) complex_type%a(), complex_type%b ! complex_type%a_int = 3 ! This should fail end program my_prog
source share