This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Fortran, Patch] PR34133 - reject binding name for dummies; relax constrain of internal bind(c) procedures


:ADDPATCH fortran:

This patch does two things:

a) It rejects bind(C,name="...") for dummy arguments; it does not make
sense to have a binding name for a dummy and it is not allowed.

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.



b) With the last patch to this PR, I rejected "bind(C)" for internal
procedures per Fortran 2003 standard:

C1237 (R1225) A proc-language-binding-spec shall not be specified for an
internal procedure.


However, as Chris pointed out in the PR, there is no reason why bind(C)
should not be specified also for internal procedures and also the
Fortran 2008 standard (draft 07-007r3) allows it. The main use as I see
it: Allowing internal, C compatible procedures as actual argument.
Fortran 2008 has (only) the following constrain on using Bind(C) for
internal procedures:

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.


This makes sense: If the procedure is not available outside the parent
procedure via Fortran, why should it be made available for C?
Additionally, no C symbol is create for such procedures ("15.5.2 Binding
labels for procedures"; Fortran 2008 draft): "If a procedure has the
BIND attribute with no NAME= specifier, and the procedure is not a dummy
procedure, internal procedure, or procedure pointer, then the binding
label of the procedure is the same as the name of the procedure using
lower case letters. Otherwise, the procedure has no binding label."

The attached patch makes this a GNU extension (which can later be turned
in -std=f2008).

When I read the PR, I thought that - since my previous patch - gfortran
rejects bind(C) internal procedures as actual argument, which was
working before. However, I was wrong: it did not work before as internal
procedures are not allowed as actual argument in Fortran 2003 (and
gfortran). (They are in Fortran 2008, see PR34162.) Thus I'm willing to
postpone this part of the patch until GCC 4.4; given that the patch is
small, I would not mind if it is accepted nonetheless.

Build and regression tested on x86-64. OK for the trunk?

Tobias

PS: Next steps on my bind(C) to-do list are afterwards:
- No char-length dummy/actual arguments for bind(c)
subroutine/function/entry
- Bind(C) character functions should return the result and not use an
argument for the result


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]