------- Comment #4 from burnus at gcc dot gnu dot org 2007-11-19 21:17 ------- (In reply to comment #3) > i don't think this constraint exists in F08 (at least i cannot find it).
You are right. However, there is still a constrain. Fortran 2003 has: C1236 (R1225) A proc-language-binding-spec with a NAME= specifier shall not be specified in the function-stmt or subroutine-stmt of an interface body for an abstract interface or a dummy procedure. C1237 (R1225) A proc-language-binding-spec shall not be specified for an internal procedure. while http://j3-fortran.org/doc/year/07/07-007r3.pdf has: 12.6.2.2 Function subprogram C1252 (R1229) A proc-language-binding-spec with a NAME= specifier shall not be specified in the function-stmt or subroutine-stmt of an internal procedure, or of an interface body for an abstract interface or a dummy procedure. Thus BIND(C) is allowed for internal procedures, but not BIND(C,name=...). I think the idea is to allow such procedures, e.g., as actual argument; one thing one needs to check is the following: How does this work in terms of name mangling? Assume the following: subroutine foo() contains subroutine bar() bind(c) end subroutine bar end subroutine foo subroutine my() bind(c,name="bar") end subroutine bar This will cause name clashes of "bar". Internal procedures have the advantage that they are internal and have no name clashes problems. I wonder what symbol should be created for the internal procedure with bind(C) symbol. Maybe this is something to check in the standard and ask at the j3 mailing list. The following is invalid per Fortran 2003 and 2008 and accepted by gfortran: subroutine bb(a) interface subroutine a() bind(c, name="foo") ! name= for dummy variable end subroutine a end interface end subroutine bb For the latter, we need a patch which rejects this outright. For the former, I think a patch makes sense which allows it (w/o name=) for -std=gnu (and add a note to PR 33197 to change the GFC_STD_GNU to GFC_STD_F2008 as soon as gfortran has it.) -- burnus at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |UNCONFIRMED Resolution|FIXED | Summary|Bind(c): Accepts PROGRAM |Bind(c,name="") should be |internal bind(c) procedure |rejected for dummies; F2008: | |allow bind(c) for internal | |procs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34133