PR tree-optimization/86415 - strlen() not folded for substrings within constant arrays
[official-gcc.git] / gcc / testsuite / gfortran.dg / c_f_pointer_shape_tests_5.f90
blobbf9fad206657026b118277233be49867b851c139
1 ! { dg-do run }
3 ! Check that C_F_Pointer works with a noncontiguous SHAPE argument
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)
12 array = [22,33,44]
13 x = c_loc(array)
14 myshape = [1,2,3,4,1]
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
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