111
|
1 ! Like array_constructor_6.f90, but check iterators with non-default stride,
|
|
2 ! including combinations which lead to zero-length vectors.
|
|
3 ! { dg-do run }
|
|
4 ! { dg-options "-Wzerotrip" }
|
|
5 program main
|
|
6 implicit none
|
|
7 call build (77)
|
|
8 contains
|
|
9 subroutine build (order)
|
|
10 integer :: order, i, j
|
|
11
|
|
12 call test (1, 11, 3, (/ (i, i = 1, 11, 3) /))
|
|
13 call test (3, 20, 2, (/ (i, i = 3, 20, 2) /))
|
|
14 call test (4, 0, 11, (/ (i, i = 4, 0, 11) /)) ! { dg-warning "will be executed zero times" }
|
|
15
|
|
16 call test (110, 10, -3, (/ (i, i = 110, 10, -3) /))
|
|
17 call test (200, 20, -12, (/ (i, i = 200, 20, -12) /))
|
|
18 call test (29, 30, -6, (/ (i, i = 29, 30, -6) /)) ! { dg-warning "will be executed zero times" }
|
|
19
|
|
20 call test (1, order, 3, (/ (i, i = 1, order, 3) /))
|
|
21 call test (order, 1, -3, (/ (i, i = order, 1, -3) /))
|
|
22
|
|
23 ! Triggers compile-time iterator calculations in trans-array.c
|
|
24 call test (1, 1000, 2, (/ (i, i = 1, 1000, 2), (i, i = order, 0, 1) /))
|
|
25 call test (1, 0, 3, (/ (i, i = 1, 0, 3), (i, i = order, 0, 1) /)) ! { dg-warning "will be executed zero times" }
|
|
26 call test (1, 2000, -5, (/ (i, i = 1, 2000, -5), (i, i = order, 0, 1) /)) ! { dg-warning "will be executed zero times" }
|
|
27 call test (3000, 99, 4, (/ (i, i = 3000, 99, 4), (i, i = order, 0, 1) /)) ! { dg-warning "will be executed zero times" }
|
|
28 call test (400, 77, -39, (/ (i, i = 400, 77, -39), (i, i = order, 0, 1) /))
|
|
29
|
|
30 do j = -10, 10
|
|
31 call test (order + j, order, 5, (/ (i, i = order + j, order, 5) /))
|
|
32 call test (order + j, order, -5, (/ (i, i = order + j, order, -5) /))
|
|
33 end do
|
|
34
|
|
35 end subroutine build
|
|
36
|
|
37 subroutine test (from, to, step, values)
|
|
38 integer, dimension (:) :: values
|
|
39 integer :: from, to, step, last, i
|
|
40
|
|
41 last = 0
|
|
42 do i = from, to, step
|
|
43 last = last + 1
|
131
|
44 if (values (last) .ne. i) STOP 1
|
111
|
45 end do
|
131
|
46 if (size (values, dim = 1) .ne. last) STOP 2
|
111
|
47 end subroutine test
|
|
48 end program main
|