------- Comment #2 from burnus at gcc dot gnu dot org  2007-11-13 20:02 -------
Note: The patch above works, one only needs to check whether there is a memory
leak or something else which affects the generated tree.

Index: gcc/testsuite/gfortran.dg/bind_c_vars_2.f03
===================================================================
--- gcc/testsuite/gfortran.dg/bind_c_vars_2.f03 (revision 0)
+++ gcc/testsuite/gfortran.dg/bind_c_vars_2.f03 (revision 0)
@@ -0,0 +1,29 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! PR fortran/34079
+! Character bind(c) arguments shall not pass the length as additional argument
+!
+implicit none
+interface
+  subroutine subiso(x) bind(c)
+    use iso_c_binding
+    character(kind=c_char,len=1), dimension(*) :: x
+  end subroutine subiso
+  subroutine subiso2(x) bind(c) ! { dg-warning "may not be C interoperable" }
+    character(len=1), dimension(*) :: x
+  end subroutine subiso2
+  subroutine sub(x)
+    use iso_c_binding
+    character(kind=c_char,len=1), dimension(*) :: x
+  end subroutine sub
+end interface
+call sub    ("abc")
+call subiso ("ABCDEF")
+call subiso2("AbCdEfGhIj")
+end
+
+! { dg-final { scan-tree-dump-times "{lb: 1 sz: 1}, 3" 1 "original" } }
+! { dg-final { scan-tree-dump-times "{lb: 1 sz: 1}, 6" 0 "original" } }
+! { dg-final { scan-tree-dump-times "{lb: 1 sz: 1}, 10" 0 "original" } }
+! { dg-final { cleanup-tree-dump "original" } }


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, wrong-code


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34079

Reply via email to