2 ! { dg-additional-sources assumed_rank_1_c.c }
12 subroutine check_value(b
, n
, val
)
19 integer, target
:: x(2:5,4:7), y(-4:4)
20 integer, allocatable
, target
:: z(:,:,:,:)
21 integer, allocatable
:: val(:)
24 allocate(z(1:4, -2:5, 4, 10:11))
26 if (rank(x
) /= 2) call abort ()
27 val
= [(2*i
+3, i
= 1, size(x
))]
28 x
= reshape (val
, shape(x
))
29 call foo(x
, rank(x
), lbound(x
), ubound(x
), val
)
30 call foo2(x
, rank(x
), lbound(x
), ubound(x
), val
)
32 call bar(x
,prsnt
=.false
.)
34 if (rank(y
) /= 1) call abort ()
35 val
= [(2*i
+7, i
= 1, size(y
))]
36 y
= reshape (val
, shape(y
))
37 call foo(y
, rank(y
), lbound(y
), ubound(y
), val
)
38 call foo2(y
, rank(y
), lbound(y
), ubound(y
), val
)
40 call bar(y
,prsnt
=.false
.)
42 if (rank(z
) /= 4) call abort ()
43 val
= [(2*i
+5, i
= 1, size(z
))]
44 z(:,:,:,:) = reshape (val
, shape(z
))
45 call foo(z
, rank(z
), lbound(z
), ubound(z
), val
)
46 call foo(z
, rank(z
), lbound(z
), ubound(z
), val
)
47 call foo2(z
, rank(z
), lbound(z
), ubound(z
), val
)
49 call bar(z
,prsnt
=.false
.)
52 subroutine bar(a
,b
, prsnt
)
53 integer, pointer, optional
, intent(in
) :: a(..),b(..)
54 logical, value
:: prsnt
55 if (.not
. associated(a
)) call abort()
57 ! The following is not valid.
58 ! Technically, it could be allowed and might be in Fortran 2015:
59 ! if (.not. associated(a,b)) call abort()
61 if (.not
. associated(a
)) call abort()
63 if (.not
. present(a
)) call abort()
64 if (prsnt
.neqv
. present(b
)) call abort()
67 ! POINTER argument - bounds as specified before
68 subroutine foo(a
, rnk
, low
, high
, val
)
69 integer,pointer, intent(in
) :: a(..)
71 integer, intent(in
) :: low(:), high(:), val(:)
76 if (rank(a
) /= rnk
) call abort()
77 if (size(low
) /= rnk
.or
. size(high
) /= rnk
) call abort()
78 if (size(a
) /= product (high
- low
+1)) call abort()
81 if (low(1) /= lbound(a
,1)) call abort()
82 if (high(1) /= ubound(a
,1)) call abort()
83 if (size (a
,1) /= high(1)-low(1)+1) call abort()
87 if (low(i
) /= lbound(a
,i
)) call abort()
88 if (high(i
) /= ubound(a
,i
)) call abort()
89 if (size (a
,i
) /= high(i
)-low(i
)+1) call abort()
91 call check_value (a
, rnk
, val
)
92 call foo2(a
, rnk
, low
, high
, val
)
95 ! Non-pointer, non-allocatable bounds. lbound == 1
96 subroutine foo2(a
, rnk
, low
, high
, val
)
97 integer, intent(in
) :: a(..)
99 integer, intent(in
) :: low(:), high(:), val(:)
102 if (rank(a
) /= rnk
) call abort()
103 if (size(low
) /= rnk
.or
. size(high
) /= rnk
) call abort()
104 if (size(a
) /= product (high
- low
+1)) call abort()
107 if (1 /= lbound(a
,1)) call abort()
108 if (high(1)-low(1)+1 /= ubound(a
,1)) call abort()
109 if (size (a
,1) /= high(1)-low(1)+1) call abort()
113 if (1 /= lbound(a
,i
)) call abort()
114 if (high(i
)-low(i
)+1 /= ubound(a
,i
)) call abort()
115 if (size (a
,i
) /= high(i
)-low(i
)+1) call abort()
117 call check_value (a
, rnk
, val
)
120 ! ALLOCATABLE argument - bounds as specified before
121 subroutine foo3 (a
, rnk
, low
, high
, val
)
122 integer, allocatable
, intent(in
), target
:: a(..)
123 integer, value
:: rnk
124 integer, intent(in
) :: low(:), high(:), val(:)
127 if (rank(a
) /= rnk
) call abort()
128 if (size(low
) /= rnk
.or
. size(high
) /= rnk
) call abort()
129 if (size(a
) /= product (high
- low
+1)) call abort()
132 if (low(1) /= lbound(a
,1)) call abort()
133 if (high(1) /= ubound(a
,1)) call abort()
134 if (size (a
,1) /= high(1)-low(1)+1) call abort()
138 if (low(i
) /= lbound(a
,i
)) call abort()
139 if (high(i
) /= ubound(a
,i
)) call abort()
140 if (size (a
,i
) /= high(i
)-low(i
)+1) call abort()
142 call check_value (a
, rnk
, val
)
143 call foo(a
, rnk
, low
, high
, val
)