RISC-V: Refactor Dynamic LMUL codes
[official-gcc.git] / gcc / testsuite / gfortran.dg / c_loc_test_20.f90
blob8e3dd8d6675477b19804e9a5690202f41b9abd91
1 ! { dg-do run }
3 ! PR fortran/38829
4 ! PR fortran/40963
5 ! PR fortran/38813
8 program testcloc
9 use, intrinsic :: iso_c_binding
10 implicit none
12 type obj
13 real :: array(10,10)
14 real, allocatable :: array2(:,:)
15 end type
17 type(obj), target :: obj1
18 type(c_ptr) :: cptr
19 integer :: i
20 real, pointer :: array(:)
22 allocate (obj1%array2(10,10))
23 obj1%array = reshape ([(i, i=1,100)], shape (obj1%array))
24 obj1%array2 = reshape ([(i, i=1,100)], shape (obj1%array))
26 cptr = c_loc (obj1%array)
27 call c_f_pointer (cptr, array, shape=[100])
28 if (any (array /= [(i, i=1,100)])) STOP 1
30 cptr = c_loc (obj1%array2)
31 call c_f_pointer (cptr, array, shape=[100])
32 if (any (array /= [(i, i=1,100)])) STOP 2
33 end program testcloc