summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/c_f_pointer_tests_8.f90
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gfortran.dg/c_f_pointer_tests_8.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/c_f_pointer_tests_8.f9037
1 files changed, 37 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/c_f_pointer_tests_8.f90 b/gcc/testsuite/gfortran.dg/c_f_pointer_tests_8.f90
new file mode 100644
index 0000000000..d82c9ea8a3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/c_f_pointer_tests_8.f90
@@ -0,0 +1,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