This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/34079] Bind(C): Don't pass the string length as argument (for STDCALL)
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Nov 2007 14:39:37 -0000
- Subject: [Bug fortran/34079] Bind(C): Don't pass the string length as argument (for STDCALL)
- References: <bug-34079-13404@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from burnus at gcc dot gnu dot org 2007-11-13 14:39 -------
Example:
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 ("abcdef")
call subiso ("ABCDEF")
call subiso2("AbCdEf")
end
Dumped tree should look like:
sub (&"abcdef"[1]{lb: 1 sz: 1}, 6);
subiso (&"ABCDEF"[1]{lb: 1 sz: 1});
subiso2 (&"ABCDEF"[1]{lb: 1 sz: 1});
Draft of a patch:
Index: gcc/fortran/trans-expr.c
===================================================================
--- gcc/fortran/trans-expr.c (Revision 130131)
+++ gcc/fortran/trans-expr.c (Arbeitskopie)
@@ -2390,8 +2390,8 @@ gfc_conv_function_call (gfc_se * se, gfc
}
/* Character strings are passed as two parameters, a length and a
- pointer. */
- if (parmse.string_length != NULL_TREE)
+ pointer - except for Bind(c) which only passes the pointer. */
+ if (parmse.string_length != NULL_TREE && !sym->attr.is_bind_c)
stringargs = gfc_chainon_list (stringargs, parmse.string_length);
arglist = gfc_chainon_list (arglist, parmse.expr);
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34079