2 ! { dg-additional-sources assumed_rank_22_aux.c }
3 ! { dg-additional-options "-fdump-tree-original" }
5 ! FIXME: wrong extend in array descriptor, see C file.
6 ! { dg-output "c_assumed - 40 - OK" { xfail *-*-* } }
7 ! { dg-output "c_assumed - 100 - OK" { xfail *-*-* } }
11 ! Contributed by Tobias Burnus
12 ! and José Rui Faustino de Sousa
17 integer, allocatable
:: B(:,:,:)
18 integer :: C(5,4,-2:-1)
21 subroutine c_assumed (x
, num
) bind(C
)
25 subroutine c_allocated (x
) bind(C
)
26 integer, allocatable
:: x(..)
30 allocate (B(-1:3,4,-1:-1))
32 call caller (a
) ! num=0: assumed-size
33 call test (b
, num
=20) ! full array
34 call test (b(:,:,0:-1), num
=40) ! zero-sized array
36 call test (c(:,:,:-1), num
=80) ! full-size slice
37 call test (c(:,:,1:-1), num
=100) !zero-size array
41 call c_assumed (b
, num
=20)
42 call c_assumed (b(:,:,0:-1), num
=40)
43 call c_assumed (c
, num
=60)
44 call c_assumed (c(:,:,:-1), num
=80)
45 call c_assumed (c(:,:,1:-1), num
=100)
50 integer :: y(-1:3,4,*)
52 call c_assumed (y
, num
=0)
54 subroutine test (x
, num
)
59 if (size (x
) /= -20) stop 1
60 elseif (num
== 20) then
61 if (size (x
) /= 20) stop 21
62 elseif (num
== 40) then
63 if (size (x
) /= 0) stop 41
64 elseif (num
== 60) then
65 if (size (x
) /= 40) stop 61
66 elseif (num
== 80) then
67 if (size (x
) /= 40) stop 81
68 elseif (num
== 100) then
69 if (size (x
) /= 0) stop 101
75 if (size (x
, dim
=1) /= 5) stop num
+ 2
76 if (size (x
, dim
=2) /= 4) stop num
+ 3
79 if (size (x
, dim
=3) /= -1) stop 4
80 elseif (num
== 20) then
81 if (size (x
, dim
=3) /= 1) stop 24
82 elseif (num
== 40) then
83 if (size (x
, dim
=3) /= 0) stop 44
84 elseif (num
== 60) then
85 if (size (x
, dim
=3) /= 2) stop 64
86 elseif (num
== 80) then
87 if (size (x
, dim
=3) /= 2) stop 84
88 elseif (num
== 100) then
89 if (size (x
, dim
=3) /= 0) stop 104
94 if (any (shape (x
) /= [5, 4, -1])) stop 5
95 elseif (num
== 20) then
96 if (any (shape (x
) /= [5, 4, 1])) stop 25
97 elseif (num
== 40) then
98 if (any (shape (x
) /= [5, 4, 0])) stop 45
99 elseif (num
== 60) then
100 if (any (shape (x
) /= [5, 4, 2])) stop 65
101 elseif (num
== 80) then
102 if (any (shape (x
) /= [5, 4, 2])) stop 85
103 elseif (num
== 100) then
104 if (any (shape (x
) /= [5, 4, 0])) stop 105
108 if (any (lbound (x
) /= [1, 1, 1])) stop num
+ 6
110 ! LBOUND (X, dim=...)
111 if (lbound (x
, dim
=1) /= 1) stop num
+ 7
112 if (lbound (x
, dim
=2) /= 1) stop num
+ 8
113 if (lbound (x
, dim
=3) /= 1) stop num
+ 9
117 if (any (ubound (x
) /= [5, 4, -1])) stop 11
118 elseif (num
== 20) then
119 if (any (ubound (x
) /= [5, 4, 1])) stop 31
120 elseif (num
== 40) then
121 if (any (ubound (x
) /= [5, 4, 0])) stop 51
122 elseif (num
== 60) then
123 if (any (ubound (x
) /= [5, 4, 2])) stop 71
124 elseif (num
== 80) then
125 if (any (ubound (x
) /= [5, 4, 2])) stop 91
126 elseif (num
== 100) then
127 if (any (ubound (x
) /= [5, 4, 0])) stop 111
130 ! UBOUND (X, dim=...)
131 if (ubound (x
, dim
=1) /= 5) stop num
+ 12
132 if (ubound (x
, dim
=2) /= 4) stop num
+ 13
134 if (ubound (x
, dim
=3) /= -1) stop 14
135 elseif (num
== 20) then
136 if (ubound (x
, dim
=3) /= 1) stop 34
137 elseif (num
== 40) then
138 if (ubound (x
, dim
=3) /= 0) stop 54
139 elseif (num
== 60) then
140 if (ubound (x
, dim
=3) /= 2) stop 74
141 elseif (num
== 80) then
142 if (ubound (x
, dim
=3) /= 2) stop 94
143 elseif (num
== 100) then
144 if (ubound (x
, dim
=3) /= 0) stop 114
148 subroutine test_alloc (x
)
149 integer, allocatable
:: x(..)
151 if (size (x
) /= 20) stop 61
152 if (size (x
, dim
=1) /= 5) stop 62
153 if (size (x
, dim
=2) /= 4) stop 63
154 if (size (x
, dim
=3) /= 1) stop 64
156 if (any (shape (x
) /= [5, 4, 1])) stop 65
158 if (any (lbound (x
) /= [-1, 1, -1])) stop 66
159 if (lbound (x
, dim
=1) /= -1) stop 77
160 if (lbound (x
, dim
=2) /= 1) stop 78
161 if (lbound (x
, dim
=3) /= -1) stop 79
163 if (any (ubound (x
) /= [3, 4, -1])) stop 80
164 if (ubound (x
, dim
=1) /= 3) stop 92
165 if (ubound (x
, dim
=2) /= 4) stop 93
166 if (ubound (x
, dim
=3) /= -1) stop 94
169 ! { dg-final { scan-tree-dump-not "_gfortran_size" "original" } }