OSDN Git Service

2007-02-03 Steven G. Kargl <kargl@gcc.gnu.org>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / derived_init_2.f90
1 ! { dg-do run }\r
2 ! PR 25217: INTENT(OUT) dummies of derived type with default initializers shall\r
3 ! be (re)initialized upon procedure entry, unless they are ALLOCATABLE.
4 ! Modified to take account of the regression, identified by Martin Tees
5 ! http://gcc.gnu.org/ml/fortran/2006-08/msg00276.html and fixed with
6 ! PR 28788.\r
7 module dt
8     type :: drv\r
9         integer :: a(3) = [ 1, 2, 3 ]\r
10         character(3) :: s = "abc"\r
11         real, pointer :: p => null()\r
12     end type drv\r
13 end module dt
14
15 module subs
16 contains
17     subroutine foo(fb)
18         use dt\r
19         type(drv), intent(out) :: fb
20         call sub (fb)
21     end subroutine foo
22 \r
23     subroutine sub(fa)
24         use dt\r
25         type(drv), intent(out) :: fa\r
26 \r
27         if (any(fa%a /= [ 1, 2, 3 ])) call abort()\r
28         if (fa%s /= "abc") call abort()\r
29         if (associated(fa%p)) call abort()\r
30     end subroutine sub
31 end module subs
32
33 program main\r
34     use dt
35     use subs\r
36     implicit none\r
37     type(drv) :: aa\r
38     type(drv), allocatable :: ab(:)\r
39     real, target :: x = 99, y = 999\r
40 \r
41     aa = drv ([ 4, 5, 6], "def", x)\r
42     call sub(aa)\r
43 \r
44     aa = drv ([ 7, 8, 9], "ghi", y)\r
45     call foo(aa)\r
46 end program main\r
47 \r
48 ! { dg-final { cleanup-modules "dt subs" } }