summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/derived_init_3.f90
blob: a1c4a0c7e0db0b629de3f5aa250707410236bc7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
! { dg-do run }
!
! PR fortran/40851
!
! Make sure the an INTENT(OUT) dummy is not initialized
! when it is a pointer.
!
! Contributed by Juergen Reuter <juergen.reuter@desy.de>.
!
program main

  type :: string
     character,dimension(:),allocatable :: chars
  end type string

  type :: string_container
     type(string) :: string
  end type string_container

  type(string_container), target :: tgt
  type(string_container), pointer :: ptr

  ptr => tgt
  call set_ptr (ptr)
  if (associated(ptr)) call abort()

contains

  subroutine set_ptr (ptr)
    type(string_container), pointer, intent(out) :: ptr
    ptr => null ()
  end subroutine set_ptr

end program main