Increase timeout factor for hppa*-*-* in gcc.dg/long_branch.c
[official-gcc.git] / gcc / testsuite / gfortran.dg / pointer_array_component_1.f90
blobcac1512954ee271bb7e4a2c154d6eda3bc0e402d
1 ! { dg-do run }
3 ! Check the fix for PR34640 comment 28.
5 ! This involves pointer array components that point to components of arrays
6 ! of derived types.
8 type var_tables
9 real, pointer :: rvar(:)
10 end type
12 type real_vars
13 real r
14 real :: index
15 end type
17 type(var_tables) :: vtab_r
18 type(real_vars), target :: x(2)
19 real, pointer :: z(:)
20 real :: y(2)
22 x = [real_vars (11.0, 1.0), real_vars (42.0, 2.0)]
23 vtab_r%rvar => x%r
24 if (any (abs (vtab_r%rvar - [11.0, 42.0]) > 1.0e-5)) STOP 1! Check skipping 'index; is OK.
26 y = vtab_r%rvar
27 if (any (abs (y - [11.0, 42.0]) > 1.0e-5)) STOP 2! Check that the component is usable in assignment.
29 call foobar (vtab_r, [11.0, 42.0])
31 vtab_r = barfoo ()
33 call foobar (vtab_r, [111.0, 142.0])
35 contains
36 subroutine foobar (vtab, array)
37 type(var_tables) :: vtab
38 real :: array (:)
39 if (any (abs (vtab%rvar - array) > 1.0e-5)) STOP 3! Check passing as a dummy.
40 if (abs (vtab%rvar(2) - array(2)) > 1.0e-5) STOP 4! Check component reference.
41 end subroutine
43 function barfoo () result(res)
44 type(var_tables) :: res
45 allocate (res%rvar(2), source = [111.0, 142.0]) ! Check allocation
46 end function
47 end