aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/shape_12.f90
blob: e672e1ff9f95d6c7205b79e9e18874eeaf6c72ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
! { dg-do run }
!
! PR fortran/115150
!
! Check that SHAPE handles zero-sized arrays correctly
!
implicit none
call one
call two

contains

subroutine one
  real,allocatable :: A(:),B(:,:)
  allocate(a(3:0), b(5:1, 2:5))

  if (any (shape(a) /= [0])) stop 1
  if (any (shape(b) /= [0, 4])) stop 2
  if (size(a) /= 0) stop 3
  if (size(b) /= 0) stop 4
  if (any (lbound(a) /= [1])) stop 5
  if (any (lbound(b) /= [1, 2])) stop 6
  if (any (ubound(a) /= [0])) stop 5
  if (any (ubound(b) /= [0,5])) stop 6
end

subroutine two
integer :: x1(10), x2(10,10)
call f(x1, x2, -3)
end

subroutine f(y1, y2, n)
  integer, value :: n
  integer :: y1(1:n)
  integer :: y2(1:n,4,2:*)
  call g(y1, y2)
end

subroutine g(z1, z2)
  integer :: z1(..), z2(..)

  if (any (shape(z1) /= [0])) stop 1
  if (any (shape(z2) /= [0, 4, -1])) stop 2
  if (size(z1) /= 0) stop 3
  if (size(z2) /= 0) stop 4
  if (any (lbound(z1) /= [1])) stop 5
  if (any (lbound(z2) /= [1, 1, 1])) stop 6
  if (any (ubound(z1) /= [0])) stop 5
  if (any (ubound(z2) /= [0, 4, -1])) stop 6
end
end