| 1 |
! { dg-do run } |
| 2 |
program foo |
| 3 |
|
| 4 |
implicit none |
| 5 |
|
| 6 |
type t |
| 7 |
integer i |
| 8 |
end type t |
| 9 |
|
| 10 |
type(t), parameter :: d(5) = [t(1), t(2), t(3), t(4), t(5)] |
| 11 |
type(t) e(5), q(5) |
| 12 |
|
| 13 |
integer, parameter :: a(5) = [1, 2, 3, 4, 5] |
| 14 |
integer i, b(5), c(5), v(5) |
| 15 |
|
| 16 |
c = [1, 2, 3, 4, 5] |
| 17 |
|
| 18 |
b = cshift(a, -2) |
| 19 |
v = cshift(c, -2) |
| 20 |
if (any(b /= v)) STOP 1 |
| 21 |
|
| 22 |
b = cshift(a, 2) |
| 23 |
v = cshift(c, 2) |
| 24 |
if (any(b /= v)) STOP 2 |
| 25 |
|
| 26 |
! Special cases shift = 0, size(a), -size(a) |
| 27 |
b = cshift([1, 2, 3, 4, 5], 0) |
| 28 |
if (any(b /= a)) STOP 3 |
| 29 |
b = cshift([1, 2, 3, 4, 5], size(a)) |
| 30 |
if (any(b /= a)) STOP 4 |
| 31 |
b = cshift([1, 2, 3, 4, 5], -size(a)) |
| 32 |
if (any(b /= a)) STOP 5 |
| 33 |
|
| 34 |
! simplification of array arg. |
| 35 |
b = cshift(2 * a, 0) |
| 36 |
if (any(b /= 2 * a)) STOP 6 |
| 37 |
|
| 38 |
! An array of derived types works too. |
| 39 |
e = [t(1), t(2), t(3), t(4), t(5)] |
| 40 |
e = cshift(e, 3) |
| 41 |
q = cshift(d, 3) |
| 42 |
do i = 1, 5 |
| 43 |
if (e(i)%i /= q(i)%i) STOP 7 |
| 44 |
end do |
| 45 |
|
| 46 |
end program foo |