PR rtl-optimization/82913
[official-gcc.git] / gcc / testsuite / gfortran.fortran-torture / execute / der_type.f90
blob6a2716407bff04f87097dc51d4321aba58858598
1 ! Program to test derived types
2 program der_type
3 implicit none
4 type t1
5 integer, dimension (4, 5) :: a
6 integer :: s
7 end type
9 type my_type
10 character(20) :: c
11 type (t1), dimension (4, 3) :: ca
12 type (t1) :: r
13 end type
15 type init_type
16 integer :: i = 13
17 integer :: j = 14
18 end type
20 type (my_type) :: var
21 type (init_type) :: def_init
22 type (init_type) :: is_init = init_type (10, 11)
23 integer i;
25 if ((def_init%i .ne. 13) .or. (def_init%j .ne. 14)) call abort
26 if ((is_init%i .ne. 10) .or. (is_init%j .ne. 11)) call abort
27 ! Passing a component as a parameter tests getting the addr of a component
28 call test_call(def_init%i)
29 var%c = "Hello World"
30 if (var%c .ne. "Hello World") call abort
31 var%r%a(:, :) = 0
32 var%ca(:, :)%s = 0
33 var%r%a(1, 1) = 42
34 var%r%a(4, 5) = 43
35 var%ca(:, :)%s = var%r%a(:, 1:5:2)
36 if (var%ca(1, 1)%s .ne. 42) call abort
37 if (var%ca(4, 3)%s .ne. 43) call abort
38 contains
39 subroutine test_call (p)
40 integer p
42 if (p .ne. 13) call abort
43 end subroutine
44 end program