[C++ PATCH] Deprecate -ffriend-injection
[official-gcc.git] / gcc / testsuite / gfortran.dg / derived_init_2.f90
blob10a16b532a26fca4f6edf90c6f41a7ac5fb3a0e6
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 ! 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.
7 module dt
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 end module dt
15 module subs
16 contains
17 subroutine foo(fb)
18 use dt
19 type(drv), intent(out) :: fb
20 call sub (fb)
21 end subroutine foo
23 subroutine sub(fa)
24 use dt
25 type(drv), intent(out) :: fa
27 if (any(fa%a /= [ 1, 2, 3 ])) call abort()
28 if (fa%s /= "abc") call abort()
29 if (associated(fa%p)) call abort()
30 end subroutine sub
31 end module subs
33 program main
34 use dt
35 use subs
36 implicit none
37 type(drv) :: aa
38 type(drv), allocatable :: ab(:)
39 real, target :: x = 99, y = 999
41 aa = drv ([ 4, 5, 6], "def", x)
42 call sub(aa)
44 aa = drv ([ 7, 8, 9], "ghi", y)
45 call foo(aa)
46 end program main