1! { dg-do run }
2!
3! Test for polymorphic coarrays
4!
5type t
6end type t
7class(t), allocatable :: A[:,:]
8allocate (A[1:4,-5:*])
9if (allocated(A)) stop
10if (any (lcobound(A) /= [1, -5])) STOP 1
11if (num_images() == 1) then
12  if (any (ucobound(A) /= [4, -5])) STOP 2
13else
14  if (ucobound(A,dim=1) /= 4) STOP 3
15end if
16if (allocated(A)) i = 5
17call s(A)
18call st(A)
19contains
20subroutine s(x)
21  class(t) :: x[4,2:*]
22  if (any (lcobound(x) /= [1, 2])) STOP 4
23  if (num_images() == 1) then
24    if (any (ucobound(x) /= [4, 2])) STOP 5
25  else
26    if (ucobound(x,dim=1) /= 4) STOP 6
27  end if
28end subroutine s
29subroutine st(x)
30  class(t) :: x[:,:]
31  if (any (lcobound(x) /= [1, -5])) STOP 7
32  if (num_images() == 1) then
33    if (any (ucobound(x) /= [4, -5])) STOP 8
34  else
35    if (ucobound(x,dim=1) /= 4) STOP 9
36  end if
37end subroutine st
38end
39
40