| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! PR fortran/115150 |
| 4 |
! |
| 5 |
! Check that SHAPE handles zero-sized arrays correctly |
| 6 |
! |
| 7 |
implicit none |
| 8 |
call one |
| 9 |
call two |
| 10 |
|
| 11 |
contains |
| 12 |
|
| 13 |
subroutine one |
| 14 |
real,allocatable :: A(:),B(:,:) |
| 15 |
allocate(a(3:0), b(5:1, 2:5)) |
| 16 |
|
| 17 |
if (any (shape(a) /= [0])) stop 1 |
| 18 |
if (any (shape(b) /= [0, 4])) stop 2 |
| 19 |
if (size(a) /= 0) stop 3 |
| 20 |
if (size(b) /= 0) stop 4 |
| 21 |
if (any (lbound(a) /= [1])) stop 5 |
| 22 |
if (any (lbound(b) /= [1, 2])) stop 6 |
| 23 |
if (any (ubound(a) /= [0])) stop 5 |
| 24 |
if (any (ubound(b) /= [0,5])) stop 6 |
| 25 |
end |
| 26 |
|
| 27 |
subroutine two |
| 28 |
integer :: x1(10), x2(10,10) |
| 29 |
call f(x1, x2, -3) |
| 30 |
end |
| 31 |
|
| 32 |
subroutine f(y1, y2, n) |
| 33 |
integer, value :: n |
| 34 |
integer :: y1(1:n) |
| 35 |
integer :: y2(1:n,4,2:*) |
| 36 |
call g(y1, y2) |
| 37 |
end |
| 38 |
|
| 39 |
subroutine g(z1, z2) |
| 40 |
integer :: z1(..), z2(..) |
| 41 |
|
| 42 |
if (any (shape(z1) /= [0])) stop 1 |
| 43 |
if (any (shape(z2) /= [0, 4, -1])) stop 2 |
| 44 |
if (size(z1) /= 0) stop 3 |
| 45 |
if (size(z2) /= 0) stop 4 |
| 46 |
if (any (lbound(z1) /= [1])) stop 5 |
| 47 |
if (any (lbound(z2) /= [1, 1, 1])) stop 6 |
| 48 |
if (any (ubound(z1) /= [0])) stop 5 |
| 49 |
if (any (ubound(z2) /= [0, 4, -1])) stop 6 |
| 50 |
end |
| 51 |
end |