OSDN Git Service

fortran/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / derived_init_2.f90
1 ! { dg-do run }
2 ! PR 25217: INTENT(OUT) dummies of derived type with default initializers shall
3 ! be (re)initialized upon procedure entry, unless they are ALLOCATABLE.
4 program main
5
6     implicit none
7
8     type :: drv
9         integer :: a(3) = [ 1, 2, 3 ]
10         character(3) :: s = "abc"
11         real, pointer :: p => null()
12     end type drv
13     type(drv) :: aa
14     type(drv), allocatable :: ab(:)
15     real, target :: x
16
17     aa%a = [ 4, 5, 6]
18     aa%s = "def"
19     aa%p => x
20     call sub(aa)
21
22     call sub2(ab)
23
24 contains
25
26     subroutine sub(fa)
27         type(drv), intent(out) :: fa
28
29         if (any(fa%a /= [ 1, 2, 3 ])) call abort()
30         if (fa%s /= "abc") call abort()
31         if (associated(fa%p)) call abort()
32     end subroutine sub
33
34     subroutine sub2(fa)
35         type(drv), allocatable, intent(out) :: fa(:)
36     end subroutine sub2
37
38 end program main