Fix warnings occured during profiledboostrap on
[official-gcc.git] / gcc / testsuite / gfortran.dg / do_1.f90
blobb041279f6d942374bbf90ad7b21138ecab86b710
1 ! { dg-do run }
2 ! { dg-options "-Wall" }
3 ! Program to check corner cases for DO statements.
4 program do_1
5 implicit none
6 integer i, j
8 ! limit=HUGE(i), step 1
9 j = 0
10 do i = HUGE(i) - 10, HUGE(i), 1
11 j = j + 1
12 end do
13 if (j .ne. 11) call abort
14 ! limit=HUGE(i), step > 1
15 j = 0
16 do i = HUGE(i) - 10, HUGE(i), 2
17 j = j + 1
18 end do
19 if (j .ne. 6) call abort
20 j = 0
21 do i = HUGE(i) - 9, HUGE(i), 2
22 j = j + 1
23 end do
24 if (j .ne. 5) call abort
26 ! Same again, but unknown loop step
27 if (test1(10, 1) .ne. 11) call abort
28 if (test1(10, 2) .ne. 6) call abort
29 if (test1(9, 2) .ne. 5) call abort
31 ! Zero iterations
32 j = 0
33 do i = 1, 0, 1 ! { dg-warning "executed zero times" }
34 j = j + 1
35 end do
36 if (j .ne. 0) call abort
37 j = 0
38 do i = 1, 0, 2 ! { dg-warning "executed zero times" }
39 j = j + 1
40 end do
41 if (j .ne. 0) call abort
42 j = 0
43 do i = 1, 2, -1 ! { dg-warning "executed zero times" }
44 j = j + 1
45 end do
46 if (j .ne. 0) call abort
47 call test2 (0, 1)
48 call test2 (0, 2)
49 call test2 (2, -1)
50 call test2 (2, -2)
52 ! Bound near smallest value
53 j = 0;
54 do i = -HUGE(i), -HUGE(i), 10
55 j = j + 1
56 end do
57 if (j .ne. 1) call abort
58 contains
59 ! Returns the number of iterations performed.
60 function test1(r, step)
61 implicit none
62 integer test1, r, step
63 integer k, n
64 k = 0
65 do n = HUGE(n) - r, HUGE(n), step
66 k = k + 1
67 end do
68 test1 = k
69 end function
71 subroutine test2 (lim, step)
72 implicit none
73 integer lim, step
74 integer k, n
75 k = 0
76 do n = 1, lim, step
77 k = k + 1
78 end do
79 if (k .ne. 0) call abort
80 end subroutine
81 end program