summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/do_iterator_2.f90
blob: 7422b9eb575e0b401dd0172bb74481036c598f86 (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
! { dg-do run }
! { dg-options "-std=legacy" }
!
! Tests the fix for pr32613 - see:
! http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/495c154ee188d7f1/ea292134fe68b1d0#ea292134fe68b1d0
!
! Contributed by Al Greynolds <awgreynolds@earthlink.net>
!
program main
  call something
end

subroutine something
!  integer i !correct results from gfortran depend on this statement (before fix)
  integer :: m = 0
  character lit*1, line*100
  lit(i) = line(i:i)
  i = 1
  n = 5
  line = 'PZ0R1'
  if (internal (1)) call abort ()
  if (m .ne. 4) call abort ()
contains
  logical function internal (j)
    intent(in) j
    do i = j, n
      k = index ('RE', lit (i))
      m = m + 1
      if (k == 0) cycle
      if (i + 1 == n) exit
    enddo
    internal = (k == 0)
  end function
end