fix pr/45972
[official-gcc.git] / gcc / testsuite / gfortran.dg / do_iterator_2.f90
blob7422b9eb575e0b401dd0172bb74481036c598f86
1 ! { dg-do run }
2 ! { dg-options "-std=legacy" }
4 ! Tests the fix for pr32613 - see:
5 ! http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/495c154ee188d7f1/ea292134fe68b1d0#ea292134fe68b1d0
7 ! Contributed by Al Greynolds <awgreynolds@earthlink.net>
9 program main
10 call something
11 end
13 subroutine something
14 ! integer i !correct results from gfortran depend on this statement (before fix)
15 integer :: m = 0
16 character lit*1, line*100
17 lit(i) = line(i:i)
18 i = 1
19 n = 5
20 line = 'PZ0R1'
21 if (internal (1)) call abort ()
22 if (m .ne. 4) call abort ()
23 contains
24 logical function internal (j)
25 intent(in) j
26 do i = j, n
27 k = index ('RE', lit (i))
28 m = m + 1
29 if (k == 0) cycle
30 if (i + 1 == n) exit
31 enddo
32 internal = (k == 0)
33 end function
34 end