| 1 |
! { dg-do run } |
| 2 |
! { dg-additional-sources PR94331.c } |
| 3 |
! |
| 4 |
! Test the fix for PR94331 |
| 5 |
! |
| 6 |
|
| 7 |
program main_p |
| 8 |
|
| 9 |
use, intrinsic :: iso_c_binding, only: & |
| 10 |
c_int |
| 11 |
|
| 12 |
implicit none |
| 13 |
|
| 14 |
integer :: i |
| 15 |
integer, parameter :: ex = 11 |
| 16 |
integer, parameter :: lb = 11 |
| 17 |
integer, parameter :: ub = ex+lb-1 |
| 18 |
integer, parameter :: u(*) = [(i, i=1,ex)] |
| 19 |
|
| 20 |
interface |
| 21 |
function checkb_p_as(a, l, u) result(c) & |
| 22 |
bind(c, name="check_bounds") |
| 23 |
use, intrinsic :: iso_c_binding, only: & |
| 24 |
c_int, c_bool |
| 25 |
implicit none |
| 26 |
integer(kind=c_int), pointer, intent(in) :: a(:) |
| 27 |
integer(kind=c_int), value, intent(in) :: l |
| 28 |
integer(kind=c_int), value, intent(in) :: u |
| 29 |
logical(kind=c_bool) :: c |
| 30 |
end function checkb_p_as |
| 31 |
function checkb_a_as(a, l, u) result(c) & |
| 32 |
bind(c, name="check_bounds") |
| 33 |
use, intrinsic :: iso_c_binding, only: & |
| 34 |
c_int, c_bool |
| 35 |
implicit none |
| 36 |
integer(kind=c_int), allocatable, intent(in) :: a(:) |
| 37 |
integer(kind=c_int), value, intent(in) :: l |
| 38 |
integer(kind=c_int), value, intent(in) :: u |
| 39 |
logical(kind=c_bool) :: c |
| 40 |
end function checkb_a_as |
| 41 |
function checkb_o_as(a, l, u) result(c) & |
| 42 |
bind(c, name="check_bounds") |
| 43 |
use, intrinsic :: iso_c_binding, only: & |
| 44 |
c_int, c_bool |
| 45 |
implicit none |
| 46 |
integer(kind=c_int), intent(in) :: a(:) |
| 47 |
integer(kind=c_int), value, intent(in) :: l |
| 48 |
integer(kind=c_int), value, intent(in) :: u |
| 49 |
logical(kind=c_bool) :: c |
| 50 |
end function checkb_o_as |
| 51 |
function checkb_p_ar(a, l, u) result(c) & |
| 52 |
bind(c, name="check_bounds") |
| 53 |
use, intrinsic :: iso_c_binding, only: & |
| 54 |
c_int, c_bool |
| 55 |
implicit none |
| 56 |
integer(kind=c_int), pointer, intent(in) :: a(..) |
| 57 |
integer(kind=c_int), value, intent(in) :: l |
| 58 |
integer(kind=c_int), value, intent(in) :: u |
| 59 |
logical(kind=c_bool) :: c |
| 60 |
end function checkb_p_ar |
| 61 |
function checkb_a_ar(a, l, u) result(c) & |
| 62 |
bind(c, name="check_bounds") |
| 63 |
use, intrinsic :: iso_c_binding, only: & |
| 64 |
c_int, c_bool |
| 65 |
implicit none |
| 66 |
integer(kind=c_int), allocatable, intent(in) :: a(..) |
| 67 |
integer(kind=c_int), value, intent(in) :: l |
| 68 |
integer(kind=c_int), value, intent(in) :: u |
| 69 |
logical(kind=c_bool) :: c |
| 70 |
end function checkb_a_ar |
| 71 |
function checkb_o_ar(a, l, u) result(c) & |
| 72 |
bind(c, name="check_bounds") |
| 73 |
use, intrinsic :: iso_c_binding, only: & |
| 74 |
c_int, c_bool |
| 75 |
implicit none |
| 76 |
integer(kind=c_int), intent(in) :: a(..) |
| 77 |
integer(kind=c_int), value, intent(in) :: l |
| 78 |
integer(kind=c_int), value, intent(in) :: u |
| 79 |
logical(kind=c_bool) :: c |
| 80 |
end function checkb_o_ar |
| 81 |
end interface |
| 82 |
|
| 83 |
integer(kind=c_int), target :: a(lb:ub) |
| 84 |
integer(kind=c_int), allocatable, target :: b(:) |
| 85 |
integer(kind=c_int), pointer :: p(:) |
| 86 |
|
| 87 |
a = u |
| 88 |
if(lbound(a,1)/=lb) stop 1 |
| 89 |
if(ubound(a,1)/=ub) stop 2 |
| 90 |
if(any(shape(a)/=[ex])) stop 3 |
| 91 |
if(.not.checkb_p_as(a, lb, ub)) stop 4 |
| 92 |
if(lbound(a,1)/=lb) stop 5 |
| 93 |
if(ubound(a,1)/=ub) stop 6 |
| 94 |
if(any(shape(a)/=[ex])) stop 7 |
| 95 |
if(any(a/=u)) stop 8 |
| 96 |
! |
| 97 |
a = u |
| 98 |
if(lbound(a,1)/=lb) stop 9 |
| 99 |
if(ubound(a,1)/=ub) stop 10 |
| 100 |
if(any(shape(a)/=[ex])) stop 11 |
| 101 |
if(.not.checkb_p_ar(a, lb, ub)) stop 12 |
| 102 |
if(lbound(a,1)/=lb) stop 13 |
| 103 |
if(ubound(a,1)/=ub) stop 14 |
| 104 |
if(any(shape(a)/=[ex])) stop 15 |
| 105 |
if(any(a/=u)) stop 16 |
| 106 |
! |
| 107 |
a = u |
| 108 |
if(lbound(a,1)/=lb) stop 17 |
| 109 |
if(ubound(a,1)/=ub) stop 18 |
| 110 |
if(any(shape(a)/=[ex])) stop 19 |
| 111 |
if(.not.checkb_o_as(a, 0, ex-1))stop 20 |
| 112 |
if(lbound(a,1)/=lb) stop 21 |
| 113 |
if(ubound(a,1)/=ub) stop 22 |
| 114 |
if(any(shape(a)/=[ex])) stop 23 |
| 115 |
if(any(a/=u)) stop 24 |
| 116 |
! |
| 117 |
a = u |
| 118 |
if(lbound(a,1)/=lb) stop 25 |
| 119 |
if(ubound(a,1)/=ub) stop 26 |
| 120 |
if(any(shape(a)/=[ex])) stop 27 |
| 121 |
if(.not.checkb_o_ar(a, 0, ex-1))stop 28 |
| 122 |
if(lbound(a,1)/=lb) stop 29 |
| 123 |
if(ubound(a,1)/=ub) stop 30 |
| 124 |
if(any(shape(a)/=[ex])) stop 31 |
| 125 |
if(any(a/=u)) stop 32 |
| 126 |
! |
| 127 |
allocate(b(lb:ub), source=u) |
| 128 |
if(lbound(b,1)/=lb) stop 33 |
| 129 |
if(ubound(b,1)/=ub) stop 34 |
| 130 |
if(any(shape(b)/=[ex])) stop 35 |
| 131 |
if(.not.checkb_p_as(b, lb, ub)) stop 36 |
| 132 |
if(.not.allocated(b)) stop 37 |
| 133 |
if(lbound(b,1)/=lb) stop 38 |
| 134 |
if(ubound(b,1)/=ub) stop 39 |
| 135 |
if(any(shape(b)/=[ex])) stop 40 |
| 136 |
if(any(b/=u)) stop 41 |
| 137 |
! |
| 138 |
deallocate(b) |
| 139 |
allocate(b(lb:ub), source=u) |
| 140 |
if(lbound(b,1)/=lb) stop 42 |
| 141 |
if(ubound(b,1)/=ub) stop 43 |
| 142 |
if(any(shape(b)/=[ex])) stop 44 |
| 143 |
if(.not.checkb_p_ar(b, lb, ub)) stop 45 |
| 144 |
if(.not.allocated(b)) stop 46 |
| 145 |
if(lbound(b,1)/=lb) stop 47 |
| 146 |
if(ubound(b,1)/=ub) stop 48 |
| 147 |
if(any(shape(b)/=[ex])) stop 49 |
| 148 |
if(any(b/=u)) stop 50 |
| 149 |
! |
| 150 |
deallocate(b) |
| 151 |
allocate(b(lb:ub), source=u) |
| 152 |
if(lbound(b,1)/=lb) stop 51 |
| 153 |
if(ubound(b,1)/=ub) stop 52 |
| 154 |
if(any(shape(b)/=[ex])) stop 53 |
| 155 |
if(.not.checkb_a_as(b, lb, ub)) stop 54 |
| 156 |
if(.not.allocated(b)) stop 55 |
| 157 |
if(lbound(b,1)/=lb) stop 56 |
| 158 |
if(ubound(b,1)/=ub) stop 57 |
| 159 |
if(any(shape(b)/=[ex])) stop 58 |
| 160 |
if(any(b/=u)) stop 59 |
| 161 |
! |
| 162 |
deallocate(b) |
| 163 |
allocate(b(lb:ub), source=u) |
| 164 |
if(lbound(b,1)/=lb) stop 60 |
| 165 |
if(ubound(b,1)/=ub) stop 61 |
| 166 |
if(any(shape(b)/=[ex])) stop 62 |
| 167 |
if(.not.checkb_a_ar(b, lb, ub)) stop 63 |
| 168 |
if(.not.allocated(b)) stop 64 |
| 169 |
if(lbound(b,1)/=lb) stop 65 |
| 170 |
if(ubound(b,1)/=ub) stop 66 |
| 171 |
if(any(shape(b)/=[ex])) stop 67 |
| 172 |
if(any(b/=u)) stop 68 |
| 173 |
! |
| 174 |
deallocate(b) |
| 175 |
allocate(b(lb:ub), source=u) |
| 176 |
if(lbound(b,1)/=lb) stop 69 |
| 177 |
if(ubound(b,1)/=ub) stop 70 |
| 178 |
if(any(shape(b)/=[ex])) stop 71 |
| 179 |
if(.not.checkb_o_as(b, 0, ex-1))stop 72 |
| 180 |
if(.not.allocated(b)) stop 73 |
| 181 |
if(lbound(b,1)/=lb) stop 74 |
| 182 |
if(ubound(b,1)/=ub) stop 75 |
| 183 |
if(any(shape(b)/=[ex])) stop 76 |
| 184 |
if(any(b/=u)) stop 77 |
| 185 |
! |
| 186 |
deallocate(b) |
| 187 |
allocate(b(lb:ub), source=u) |
| 188 |
if(lbound(b,1)/=lb) stop 78 |
| 189 |
if(ubound(b,1)/=ub) stop 79 |
| 190 |
if(any(shape(b)/=[ex])) stop 80 |
| 191 |
if(.not.checkb_o_ar(b, 0, ex-1))stop 81 |
| 192 |
if(.not.allocated(b)) stop 82 |
| 193 |
if(lbound(b,1)/=lb) stop 83 |
| 194 |
if(ubound(b,1)/=ub) stop 84 |
| 195 |
if(any(shape(b)/=[ex])) stop 85 |
| 196 |
if(any(b/=u)) stop 86 |
| 197 |
deallocate(b) |
| 198 |
! |
| 199 |
p(lb:ub) => a |
| 200 |
if(lbound(p,1)/=lb) stop 87 |
| 201 |
if(ubound(p,1)/=ub) stop 88 |
| 202 |
if(any(shape(p)/=[ex])) stop 89 |
| 203 |
if(.not.checkb_p_as(p, lb, ub)) stop 90 |
| 204 |
if(.not.associated(p)) stop 91 |
| 205 |
if(.not.associated(p, a)) stop 92 |
| 206 |
if(lbound(p,1)/=lb) stop 93 |
| 207 |
if(ubound(p,1)/=ub) stop 94 |
| 208 |
if(any(shape(p)/=[ex])) stop 95 |
| 209 |
if(any(p/=u)) stop 96 |
| 210 |
! |
| 211 |
nullify(p) |
| 212 |
p(lb:ub) => a |
| 213 |
if(lbound(p,1)/=lb) stop 97 |
| 214 |
if(ubound(p,1)/=ub) stop 98 |
| 215 |
if(any(shape(p)/=[ex])) stop 99 |
| 216 |
if(.not.checkb_p_ar(p, lb, ub)) stop 100 |
| 217 |
if(.not.associated(p)) stop 101 |
| 218 |
if(.not.associated(p, a)) stop 102 |
| 219 |
if(lbound(p,1)/=lb) stop 103 |
| 220 |
if(ubound(p,1)/=ub) stop 104 |
| 221 |
if(any(shape(p)/=[ex])) stop 105 |
| 222 |
if(any(p/=u)) stop 106 |
| 223 |
! |
| 224 |
nullify(p) |
| 225 |
p(lb:ub) => a |
| 226 |
if(lbound(p,1)/=lb) stop 107 |
| 227 |
if(ubound(p,1)/=ub) stop 108 |
| 228 |
if(any(shape(p)/=[ex])) stop 109 |
| 229 |
if(.not.checkb_o_as(p, 0, ex-1))stop 110 |
| 230 |
if(.not.associated(p)) stop 111 |
| 231 |
if(.not.associated(p, a)) stop 112 |
| 232 |
if(lbound(p,1)/=lb) stop 113 |
| 233 |
if(ubound(p,1)/=ub) stop 114 |
| 234 |
if(any(shape(p)/=[ex])) stop 115 |
| 235 |
if(any(p/=u)) stop 116 |
| 236 |
! |
| 237 |
nullify(p) |
| 238 |
p(lb:ub) => a |
| 239 |
if(lbound(p,1)/=lb) stop 117 |
| 240 |
if(ubound(p,1)/=ub) stop 118 |
| 241 |
if(any(shape(p)/=[ex])) stop 119 |
| 242 |
if(.not.checkb_o_ar(p, 0, ex-1))stop 120 |
| 243 |
if(.not.associated(p)) stop 121 |
| 244 |
if(.not.associated(p, a)) stop 122 |
| 245 |
if(lbound(p,1)/=lb) stop 123 |
| 246 |
if(ubound(p,1)/=ub) stop 124 |
| 247 |
if(any(shape(p)/=[ex])) stop 125 |
| 248 |
if(any(p/=u)) stop 126 |
| 249 |
nullify(p) |
| 250 |
stop |
| 251 |
|
| 252 |
end program main_p |