+2008-08-24 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/37201
+ * trans-expr.c (gfc_conv_function_call): Add string_length
+ for character-returning bind(C) functions.
+
2008-08-24 Daniel Kraft <d@domob.eu>
* gfortran.h (gfc_typebound_proc): New struct.
gfc_finish_interface_mapping (&mapping, &se->pre, &se->post);
ts = sym->ts;
- if (ts.type == BT_CHARACTER && !sym->attr.is_bind_c)
+ if (ts.type == BT_CHARACTER && sym->attr.is_bind_c)
+ se->string_length = build_int_cst (gfc_charlen_type_node, 1);
+ else if (ts.type == BT_CHARACTER)
{
if (sym->ts.cl->length == NULL)
{
+2008-08-24 Tobias Burnus <burnus@net-b.de>
+
+ PR fortran/37201
+ * gfortran.dg/bind_c_usage_17.f90: New.
+ * gfortran.dg/bind_c_usage_17_c.c: New.
+
2008-08-24 Daniel Kraft <d@domob.eu>
* gfortran.dg/finalize_5.f03: Adapted expected error message to changes
--- /dev/null
+! { dg-do run }
+! { dg-additional-sources bind_c_usage_17_c.c }
+!
+! PR fortran/37201
+!
+!
+!
+MODULE mod
+ INTERFACE
+ FUNCTION cdir() BIND(C,name="cdir") RESULT(r)
+ USE iso_c_binding
+ CHARACTER(kind=C_CHAR) :: r
+ END FUNCTION
+ END INTERFACE
+END MODULE
+
+PROGRAM test
+ USE mod
+ integer :: i = -43
+ character(len=1) :: str1
+ character(len=4) :: str4
+ str1 = 'x'
+ str4 = 'xyzz'
+ str1 = cdir()
+ if(str1 /= '/') call abort()
+ str4 = cdir()
+ if(str4 /= '/' .or. ichar(str4(2:2)) /= 32) call abort()
+ i = ICHAR(cdir())
+ if (i /= 47) call abort()
+ str4 = 'xyzz'
+ WRITE(str4,'(a)') cdir()
+ if(str4 /= '/' .or. ichar(str4(2:2)) /= 32) call abort()
+ str4 = 'xyzz'
+ WRITE(str4,'(i0)') ICHAR(cdir())
+ if(str4 /= '47' .or. ichar(str4(3:3)) /= 32) call abort()
+END PROGRAM
+
+! { dg-final { cleanup-modules "mod" } }
--- /dev/null
+/* PR fortran/37201.
+ Linked with bind_c_usage_17.f90. */
+
+char cdir(void){return '/';}