This is the mail archive of the mailing list for the GCC 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,gfortran] PR 23843: IO on derived types with PRIVATE components

Erik Edelmann wrote:
> :ADDPATCH fortran:
> Here is a patch for PR 23843.
> Currently we reject code like
> ------------------
> module gfortran2
>     type tp
>         private
>         integer :: i
>     end type
> contains
>     subroutine test(x)
>         type(tp), intent(in) :: x
>         write(*,*) x
>     end subroutine test
> end module
> ------------------
> with the error message
>         write(*,*) x
>                    1
>     Error: Data transfer element at (1) cannot have PRIVATE components
> This is because, in resolve.c/resolve_transfer() we only check if
> the type to be transferred has private components, but not if it
> is defined in the same module.  To fix the problem, I added a check to
> see if the type is use associated.

While the patch certainly does the right thing, there's other stuff that we
get wrong before and after:
schluter@pcl247d:~/src/tests> cat derio.f90
module gfortran2
    type tp1
        integer :: i
    end type
    type tp
        type (tp1) :: t
    end type tp
end module
use gfortran2
type (tp) :: x
print *, x
schluter@pcl247d:~/src/tests> ~/src/gcc/build/gcc/f951 derio.f90
Execution times (seconds)
 parser                :   0.00 ( 0%) usr   0.00 ( 0%) sys   0.01 (50%) wall
    61 kB (11%) ggc
 TOTAL                 :   0.01             0.00             0.02
   551 kB
Extra diagnostic checks enabled; compiler may run slowly.
Configure with --disable-checking to disable checks.

This is because we don't look through the elements of the type to determine if
it ultimately contains PRIVATE components, but only look at the first level.
Your patch is ok to fix the PR, but I'd prefer if this issue were fixed at the
same time.

- Tobi

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