arm: Add .type and .size to __gnu_cmse_nonsecure_call [PR115360]
[official-gcc.git] / gcc / testsuite / gfortran.dg / bound_7.f90
blob179708762506a8a4b40c95a089cfbc4882b458d4
1 ! { dg-do run }
2 ! { dg-options "-std=gnu" }
3 ! PR fortran/29391
4 ! This file is here to check that LBOUND and UBOUND return correct values
6 ! Contributed by Francois-Xavier Coudert (coudert@clipper.ens.fr)
7 implicit none
8 integer, allocatable :: i(:,:), j(:), u(:,:,:,:)
10 allocate (i(-1:1,-1:1))
11 i = 0
12 allocate (j(-1:2))
13 j = 0
14 allocate (u(7,4,2,9))
16 call foo(u,4)
17 call jackal(-1,-8)
18 call jackal(-1,8)
20 if (any(lbound(i(-1:1,-1:1)) /= 1)) STOP 1
21 if (lbound(i(-1:1,-1:1), 1) /= 1) STOP 2
22 if (lbound(i(-1:1,-1:1), 2) /= 1) STOP 3
24 if (any(ubound(i(-1:1,-1:1)) /= 3)) STOP 4
25 if (ubound(i(-1:1,-1:1), 1) /= 3) STOP 5
26 if (ubound(i(-1:1,-1:1), 2) /= 3) STOP 6
28 if (any(lbound(i(:,:)) /= 1)) STOP 7
29 if (lbound(i(:,:), 1) /= 1) STOP 8
30 if (lbound(i(:,:), 2) /= 1) STOP 9
32 if (any(ubound(i(:,:)) /= 3)) STOP 10
33 if (ubound(i(:,:), 1) /= 3) STOP 11
34 if (ubound(i(:,:), 2) /= 3) STOP 12
36 if (any(lbound(i(0:,-1:)) /= 1)) STOP 13
37 if (lbound(i(0:,-1:), 1) /= 1) STOP 14
38 if (lbound(i(0:,-1:), 2) /= 1) STOP 15
40 if (any(ubound(i(0:,-1:)) /= [2,3])) STOP 16
41 if (ubound(i(0:,-1:), 1) /= 2) STOP 17
42 if (ubound(i(0:,-1:), 2) /= 3) STOP 18
44 if (any(lbound(i(:0,:0)) /= 1)) STOP 19
45 if (lbound(i(:0,:0), 1) /= 1) STOP 20
46 if (lbound(i(:0,:0), 2) /= 1) STOP 21
48 if (any(ubound(i(:0,:0)) /= 2)) STOP 22
49 if (ubound(i(:0,:0), 1) /= 2) STOP 23
50 if (ubound(i(:0,:0), 2) /= 2) STOP 24
52 if (any(lbound(transpose(i)) /= 1)) STOP 25
53 if (lbound(transpose(i), 1) /= 1) STOP 26
54 if (lbound(transpose(i), 2) /= 1) STOP 27
56 if (any(ubound(transpose(i)) /= 3)) STOP 28
57 if (ubound(transpose(i), 1) /= 3) STOP 29
58 if (ubound(transpose(i), 2) /= 3) STOP 30
60 if (any(lbound(reshape(i,[2,2])) /= 1)) STOP 31
61 if (lbound(reshape(i,[2,2]), 1) /= 1) STOP 32
62 if (lbound(reshape(i,[2,2]), 2) /= 1) STOP 33
64 if (any(ubound(reshape(i,[2,2])) /= 2)) STOP 34
65 if (ubound(reshape(i,[2,2]), 1) /= 2) STOP 35
66 if (ubound(reshape(i,[2,2]), 2) /= 2) STOP 36
68 if (any(lbound(cshift(i,-1)) /= 1)) STOP 37
69 if (lbound(cshift(i,-1), 1) /= 1) STOP 38
70 if (lbound(cshift(i,-1), 2) /= 1) STOP 39
72 if (any(ubound(cshift(i,-1)) /= 3)) STOP 40
73 if (ubound(cshift(i,-1), 1) /= 3) STOP 41
74 if (ubound(cshift(i,-1), 2) /= 3) STOP 42
76 if (any(lbound(eoshift(i,-1)) /= 1)) STOP 43
77 if (lbound(eoshift(i,-1), 1) /= 1) STOP 44
78 if (lbound(eoshift(i,-1), 2) /= 1) STOP 45
80 if (any(ubound(eoshift(i,-1)) /= 3)) STOP 46
81 if (ubound(eoshift(i,-1), 1) /= 3) STOP 47
82 if (ubound(eoshift(i,-1), 2) /= 3) STOP 48
84 if (any(lbound(spread(i,1,2)) /= 1)) STOP 49
85 if (lbound(spread(i,1,2), 1) /= 1) STOP 50
86 if (lbound(spread(i,1,2), 2) /= 1) STOP 51
88 if (any(ubound(spread(i,1,2)) /= [2,3,3])) STOP 52
89 if (ubound(spread(i,1,2), 1) /= 2) STOP 53
90 if (ubound(spread(i,1,2), 2) /= 3) STOP 54
91 if (ubound(spread(i,1,2), 3) /= 3) STOP 55
93 if (any(lbound(maxloc(i)) /= 1)) STOP 56
94 if (lbound(maxloc(i), 1) /= 1) STOP 57
96 if (any(ubound(maxloc(i)) /= 2)) STOP 58
97 if (ubound(maxloc(i), 1) /= 2) STOP 59
99 if (any(lbound(minloc(i)) /= 1)) STOP 60
100 if (lbound(minloc(i), 1) /= 1) STOP 61
102 if (any(ubound(minloc(i)) /= 2)) STOP 62
103 if (ubound(minloc(i), 1) /= 2) STOP 63
105 if (any(lbound(maxval(i,2)) /= 1)) STOP 64
106 if (lbound(maxval(i,2), 1) /= 1) STOP 65
108 if (any(ubound(maxval(i,2)) /= 3)) STOP 66
109 if (ubound(maxval(i,2), 1) /= 3) STOP 67
111 if (any(lbound(minval(i,2)) /= 1)) STOP 68
112 if (lbound(minval(i,2), 1) /= 1) STOP 69
114 if (any(ubound(minval(i,2)) /= 3)) STOP 70
115 if (ubound(minval(i,2), 1) /= 3) STOP 71
117 if (any(lbound(any(i==1,2)) /= 1)) STOP 72
118 if (lbound(any(i==1,2), 1) /= 1) STOP 73
120 if (any(ubound(any(i==1,2)) /= 3)) STOP 74
121 if (ubound(any(i==1,2), 1) /= 3) STOP 75
123 if (any(lbound(count(i==1,2)) /= 1)) STOP 76
124 if (lbound(count(i==1,2), 1) /= 1) STOP 77
126 if (any(ubound(count(i==1,2)) /= 3)) STOP 78
127 if (ubound(count(i==1,2), 1) /= 3) STOP 79
129 if (any(lbound(merge(i,i,.true.)) /= 1)) STOP 80
130 if (lbound(merge(i,i,.true.), 1) /= 1) STOP 81
131 if (lbound(merge(i,i,.true.), 2) /= 1) STOP 82
133 if (any(ubound(merge(i,i,.true.)) /= 3)) STOP 83
134 if (ubound(merge(i,i,.true.), 1) /= 3) STOP 84
135 if (ubound(merge(i,i,.true.), 2) /= 3) STOP 85
137 if (any(lbound(lbound(i)) /= 1)) STOP 86
138 if (lbound(lbound(i), 1) /= 1) STOP 87
140 if (any(ubound(lbound(i)) /= 2)) STOP 88
141 if (ubound(lbound(i), 1) /= 2) STOP 89
143 if (any(lbound(ubound(i)) /= 1)) STOP 90
144 if (lbound(ubound(i), 1) /= 1) STOP 91
146 if (any(ubound(ubound(i)) /= 2)) STOP 92
147 if (ubound(ubound(i), 1) /= 2) STOP 93
149 if (any(lbound(shape(i)) /= 1)) STOP 94
150 if (lbound(shape(i), 1) /= 1) STOP 95
152 if (any(ubound(shape(i)) /= 2)) STOP 96
153 if (ubound(shape(i), 1) /= 2) STOP 97
155 if (any(lbound(product(i,2)) /= 1)) STOP 98
156 if (any(ubound(product(i,2)) /= 3)) STOP 99
157 if (any(lbound(sum(i,2)) /= 1)) STOP 100
158 if (any(ubound(sum(i,2)) /= 3)) STOP 101
159 if (any(lbound(matmul(i,i)) /= 1)) STOP 102
160 if (any(ubound(matmul(i,i)) /= 3)) STOP 103
161 if (any(lbound(pack(i,.true.)) /= 1)) STOP 104
162 if (any(ubound(pack(i,.true.)) /= 9)) STOP 105
163 if (any(lbound(unpack(j,[.true.],[2])) /= 1)) STOP 106
164 if (any(ubound(unpack(j,[.true.],[2])) /= 1)) STOP 107
166 call sub1(i,3)
167 call sub1(reshape([7,9,4,6,7,9],[3,2]),3)
168 call sub2
170 contains
172 subroutine sub1(a,n)
173 integer :: n, a(2:n+1,4:*)
175 if (any([lbound(a,1), lbound(a,2)] /= [2, 4])) STOP 108
176 if (any(lbound(a) /= [2, 4])) STOP 109
177 end subroutine sub1
179 subroutine sub2
180 integer :: x(3:2, 1:2)
182 if (size(x) /= 0) STOP 110
183 if (lbound (x, 1) /= 1 .or. lbound(x, 2) /= 1) STOP 111
184 if (any (lbound (x) /= [1, 1])) STOP 112
185 if (ubound (x, 1) /= 0 .or. ubound(x, 2) /= 2) STOP 113
186 if (any (ubound (x) /= [0, 2])) STOP 114
187 end subroutine sub2
189 subroutine sub3
190 integer :: x(4:5, 1:2)
192 if (size(x) /= 0) STOP 115
193 if (lbound (x, 1) /= 4 .or. lbound(x, 2) /= 1) STOP 116
194 if (any (lbound (x) /= [4, 1])) STOP 117
195 if (ubound (x, 1) /= 4 .or. ubound(x, 2) /= 2) STOP 118
196 if (any (ubound (x) /= [4, 2])) STOP 119
197 end subroutine sub3
199 subroutine foo (x,n)
200 integer :: x(7,n,2,*), n
202 if (ubound(x,1) /= 7 .or. ubound(x,2) /= 4 .or. ubound(x,3) /= 2) STOP 120
203 end subroutine foo
205 subroutine jackal (b, c)
206 integer :: b, c
207 integer :: soda(b:c, 3:4)
209 if (b > c) then
210 if (size(soda) /= 0) STOP 121
211 if (lbound (soda, 1) /= 1 .or. ubound (soda, 1) /= 0) STOP 122
212 else
213 if (size(soda) /= 2*(c-b+1)) STOP 123
214 if (lbound (soda, 1) /= b .or. ubound (soda, 1) /= c) STOP 124
215 end if
217 if (lbound (soda, 2) /= 3 .or. ubound (soda, 2) /= 4) STOP 125
218 if (any (lbound (soda) /= [lbound(soda,1), lbound(soda,2)])) STOP 126
219 if (any (ubound (soda) /= [ubound(soda,1), ubound(soda,2)])) STOP 127
221 end subroutine jackal