Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gfortran.dg / c_f_pointer_tests_3.f90
blob3b28f52b4e7a6a993bae7c1e43ead3ac55ff0aca
1 ! { dg-do compile }
2 ! { dg-options "-O2 -fdump-tree-original" }
4 ! PR fortran/32600 c_f_pointer w/o shape
5 ! PR fortran/32580 c_f_procpointer
7 ! Verify that c_f_prointer [w/o shape] and c_f_procpointer generate
8 ! the right code - and no library call
10 program test
11 use iso_c_binding
12 implicit none
13 type(c_ptr) :: cptr
14 type(c_funptr) :: cfunptr
15 integer(4), pointer :: fptr
16 integer(4), pointer :: fptr_array(:)
17 procedure(integer(4)), pointer :: fprocptr
19 call c_f_pointer(cptr, fptr)
20 call c_f_pointer(cptr, fptr_array, [ 1 ])
21 call c_f_procpointer(cfunptr, fprocptr)
22 end program test
24 ! Make sure there is only a single function call:
25 ! { dg-final { scan-tree-dump-times "c_f" 1 "original" } }
26 ! { dg-final { scan-tree-dump-times "c_f_pointer" 1 "original" } }
27 ! { dg-final { scan-tree-dump-times "c_f_pointer_i4" 1 "original" } }
29 ! Check scalar c_f_pointer
30 ! { dg-final { scan-tree-dump-times " fptr = .integer.kind=4. .. cptr" 1 "original" } }
32 ! Check c_f_procpointer
33 ! { dg-final { scan-tree-dump-times " fprocptr = .integer.kind=4. .\\*<.*>. .void.. cfunptr;" 1 "original" } }
35 ! { dg-final { cleanup-tree-dump "original" } }