summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/elemental_subroutine_7.f90
blob: 7c7875bbfcd3945e89e407a7bb144fd0c69a1ad8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
! { dg-do run }
!
! PR fortran/38669
! Loop bounds temporaries used before being defined for elemental subroutines
!
! Original testcase by Harald Anlauf <anlauf@gmx.de>

program gfcbu84_main
  implicit none
  integer           :: jplev, k_lev
  integer :: p(42)
  real    :: r(42)
  integer, pointer :: q(:)
  jplev = 42
  k_lev = 1
  call random_number (r)
  p = 41 * r + 1
  allocate (q(jplev))

  q = 0
  call tq_tvgh (q(k_lev:), p(k_lev:))
  if (any (p /= q)) call abort

  q = 0
  call tq_tvgh (q(k_lev:), (p(k_lev:)))
  if (any (p /= q)) call abort

  q = 0
  call tq_tvgh (q(k_lev:), (p(p(k_lev:))))
  if (any (p(p) /= q)) call abort

  deallocate (q)

  contains
  elemental subroutine tq_tvgh (t, p)
    integer ,intent (out)            :: t
    integer ,intent (in)             :: p
    t=p
  end subroutine tq_tvgh
end program gfcbu84_main