2 ! { dg-options "-std=legacy -ffree-line-length-none -fno-range-check -fwrapv -Wzerotrip" }
9 #define TEST_LOOP(var,from,to,step,total,test,final) \
10 count = 0 ; do var = from, to, step ; count = count + 1 ; end do ; \
11 if (count /= total) call abort ; \
12 if (test (from, to, step, final) /= total) call abort
15 TEST_LOOP(i, 0, 0, 1, 1, test_i, 1)
16 TEST_LOOP(i, 0, 0, 2, 1, test_i, 2)
17 TEST_LOOP(i, 0, 0, -1, 1, test_i, -1)
18 TEST_LOOP(i, 0, 0, -2, 1, test_i, -2)
20 TEST_LOOP(i, 0, 1, 1, 2, test_i, 2)
21 TEST_LOOP(i, 0, 1, 2, 1, test_i, 2)
22 TEST_LOOP(i, 0, 1, 3, 1, test_i, 3)
23 TEST_LOOP(i, 0, 1, huge(0), 1, test_i, huge(0))
24 TEST_LOOP(i, 0, 1, -1, 0, test_i, 0) ! { dg-warning "executed zero times" }
25 TEST_LOOP(i, 0, 1, -2, 0, test_i, 0) ! { dg-warning "executed zero times" }
26 TEST_LOOP(i, 0, 1, -3, 0, test_i, 0) ! { dg-warning "executed zero times" }
27 TEST_LOOP(i, 0, 1, -huge(0), 0, test_i, 0) ! { dg-warning "executed zero times" }
28 TEST_LOOP(i, 0, 1, -huge(0)-1, 0, test_i, 0) ! { dg-warning "executed zero times" }
30 TEST_LOOP(i, 1, 0, 1, 0, test_i, 1) ! { dg-warning "executed zero times" }
31 TEST_LOOP(i, 1, 0, 2, 0, test_i, 1) ! { dg-warning "executed zero times" }
32 TEST_LOOP(i, 1, 0, 3, 0, test_i, 1) ! { dg-warning "executed zero times" }
33 TEST_LOOP(i, 1, 0, huge(0), 0, test_i, 1) ! { dg-warning "executed zero times" }
34 TEST_LOOP(i, 1, 0, -1, 2, test_i, -1)
35 TEST_LOOP(i, 1, 0, -2, 1, test_i, -1)
36 TEST_LOOP(i, 1, 0, -3, 1, test_i, -2)
37 TEST_LOOP(i, 1, 0, -huge(0), 1, test_i, 1-huge(0))
38 TEST_LOOP(i, 1, 0, -huge(0)-1, 1, test_i, -huge(0))
40 TEST_LOOP(i, 0, 17, 1, 18, test_i, 18)
41 TEST_LOOP(i, 0, 17, 2, 9, test_i, 18)
42 TEST_LOOP(i, 0, 17, 3, 6, test_i, 18)
43 TEST_LOOP(i, 0, 17, 4, 5, test_i, 20)
44 TEST_LOOP(i, 0, 17, 5, 4, test_i, 20)
45 TEST_LOOP(i, 17, 0, -1, 18, test_i, -1)
46 TEST_LOOP(i, 17, 0, -2, 9, test_i, -1)
47 TEST_LOOP(i, 17, 0, -3, 6, test_i, -1)
48 TEST_LOOP(i, 17, 0, -4, 5, test_i, -3)
49 TEST_LOOP(i, 17, 0, -5, 4, test_i, -3)
51 TEST_LOOP(i1, -huge(i1)-1_1, huge(i1), 2_1, int(huge(i1))+1, test_i1, huge(i1)+1_1)
52 TEST_LOOP(i1, -huge(i1)-1_1, huge(i1), huge(i1), 3, test_i1, 2_1*huge(i1)-1_1)
54 TEST_LOOP(i1, huge(i1), -huge(i1)-1_1, -2_1, int(huge(i1))+1, test_i1, -huge(i1)-2_1)
55 TEST_LOOP(i1, huge(i1), -huge(i1)-1_1, -huge(i1), 3, test_i1, -2_1*huge(i1))
56 TEST_LOOP(i1, huge(i1), -huge(i1)-1_1, -huge(i1)-1_1, 2, test_i1, -huge(i1)-2_1)
58 TEST_LOOP(i1, -2_1, 3_1, huge(i1), 1, test_i1, huge(i1)-2_1)
59 TEST_LOOP(i1, -2_1, 3_1, -huge(i1), 0, test_i1, -2_1) ! { dg-warning "executed zero times" }
60 TEST_LOOP(i1, 2_1, -3_1, -huge(i1), 1, test_i1, 2_1-huge(i1))
61 TEST_LOOP(i1, 2_1, -3_1, huge(i1), 0, test_i1, 2_1) ! { dg-warning "executed zero times" }
64 TEST_LOOP(r, 0.0, 1.0, 0.11, 1 + int(1.0/0.11), test_r, 0.0)
65 TEST_LOOP(r, 0.0, 1.0, -0.11, 0, test_r, 0.0) ! { dg-warning "executed zero times" }
66 TEST_LOOP(r, 0.0, -1.0, 0.11, 0, test_r, 0.0) ! { dg-warning "executed zero times" }
67 TEST_LOOP(r, 0.0, -1.0, -0.11, 1 + int(1.0/0.11), test_r, 0.0)
68 TEST_LOOP(r, 0.0, 0.0, 0.11, 1, test_r, 0.0)
69 TEST_LOOP(r, 0.0, 0.0, -0.11, 1, test_r, 0.0)
75 function test_i1 (from, to, step, final) result(res)
76 integer(kind=1), intent(in) :: from, to, step, final
84 if (i /= final) call abort
87 function test_i (from, to, step, final) result(res)
88 integer, intent(in) :: from, to, step, final
96 if (i /= final) call abort
99 function test_r (from, to, step, final) result(res)
100 real, intent(in) :: from, to, step, final
105 do i = from, to, step