OSDN Git Service

Fix PR42186.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / c_f_pointer_tests_2.f03
1 ! { dg-do compile }
2 ! This should compile.  There was a bug in resolving c_f_pointer that was 
3 ! caused by not sorting the actual args to match the order of the formal args.
4 ! PR fortran/32800
5 !
6 FUNCTION C_F_STRING(CPTR) RESULT(FPTR)
7   USE ISO_C_BINDING
8   implicit none
9   TYPE(C_PTR), INTENT(IN) :: CPTR ! The C address
10   CHARACTER(KIND=C_CHAR), DIMENSION(:), POINTER :: FPTR
11   INTERFACE
12      FUNCTION strlen(string) RESULT(len) BIND(C,NAME="strlen")
13        import
14        TYPE(C_PTR), VALUE :: string ! A C pointer
15        integer(c_int) :: len
16      END FUNCTION strlen
17   END INTERFACE
18   CALL C_F_POINTER(FPTR=FPTR, CPTR=CPTR,SHAPE=[strlen(cptr)])
19 END FUNCTION C_F_STRING
20