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