| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! Check that C_F_Pointer works with a noncontiguous SHAPE argument |
| 4 |
! |
| 5 |
use iso_c_binding |
| 6 |
type(c_ptr) :: x |
| 7 |
integer, target :: array(3) |
| 8 |
integer, pointer :: ptr(:,:) |
| 9 |
integer, pointer :: ptr2(:,:,:) |
| 10 |
integer :: myshape(5) |
| 11 |
|
| 12 |
array = [22,33,44] |
| 13 |
x = c_loc(array) |
| 14 |
myshape = [1,2,3,4,1] |
| 15 |
|
| 16 |
call c_f_pointer(x, ptr, shape=myshape(1:4:2)) |
| 17 |
if (any (lbound(ptr) /= [ 1, 1])) STOP 1 |
| 18 |
if (any (ubound(ptr) /= [ 1, 3])) STOP 2 |
| 19 |
if (any (shape(ptr) /= [ 1, 3])) STOP 3 |
| 20 |
if (any (ptr(1,:) /= array)) STOP 4 |
| 21 |
|
| 22 |
call c_f_pointer(x, ptr2, shape=myshape([1,3,1])) |
| 23 |
if (any (lbound(ptr2) /= [ 1, 1, 1])) STOP 5 |
| 24 |
if (any (ubound(ptr2) /= [ 1, 3, 1])) STOP 6 |
| 25 |
if (any (shape(ptr2) /= [ 1, 3, 1])) STOP 7 |
| 26 |
if (any (ptr2(1,:,1) /= array)) STOP 8 |
| 27 |
end |