aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/c_f_pointer_tests_8.f90
blob: d82c9ea8a3c6aaaaea6dec06b5ef80de298d3731 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
! { dg-do compile }
! { dg-options "-std=f2003" }
!
! PR fortran/57834
!
! (Gave a bogus warning before.)
!
program main

    use iso_c_binding
    use iso_fortran_env

    implicit none

    interface
        function strerror(errno) bind(C, NAME = 'strerror')
            import
            type(C_PTR) :: strerror
            integer(C_INT), value :: errno
        end function
    end interface

    integer :: i
    type(C_PTR) :: cptr
    character(KIND=C_CHAR), pointer :: str(:)

    cptr = strerror(INT(42, KIND = C_INT))
    call C_F_POINTER(cptr, str, [255])

    do i = 1, SIZE(str)
        if (str(i) == C_NULL_CHAR) exit
        write (ERROR_UNIT, '(A1)', ADVANCE = 'NO') str(i:i)
    enddo

    write (ERROR_UNIT, '(1X)')

end program main