[Patch, Fortran] PR48858/55465 - permit multiple bind(C) declarations (but not definitions) for the same proc
Tobias Burnus
burnus@net-b.de
Fri May 17 06:45:00 GMT 2013
Followup (and depending on) to the C binding patches for
* COMMON: http://gcc.gnu.org/ml/fortran/2013-05/msg00048.html
* Procedures: http://gcc.gnu.org/ml/fortran/2013-05/msg00051.html
which honour Fortran 2008, where the Fortran name is no longer a global
identifier if a binding name has been specified.
The main reason for this patch is a build failure of Open MPI (requires
!gcc$ attributes no_arg_check, i.e. it only affects GCC 4.9). Open MPI
uses somethine like:
interface
subroutine pmpi_something() bind(C,name="MPI_something")
...
and in a different module:
interface
subroutine mpi_something() bind(C,name="MPI_something")
...
Currently, gfortran rejects it because it only permits one
definition/declaration per translation unit. However, there is no reason
why multiple INTERFACE blocks shouldn't be permitted.
Remarks:
a) Better argument checks if definition and declaration are in the same
file. (see INTENT patch in a test case)
b) Currently, no check is done regarding the characteristic of procedure
declarations. Of course, the declaration has to be compatible with the C
procedure. However, there seems to be the wish* to permit compatible
input - even if the Fortran characteristic is different. For instance
"int *" takes both a scalar integer ("int i; f(&i)") and arrays ("int
i[5]; f(i)"). Or also popular according to the PRs: Taking a C_LOC or an
integer(c_intptr_t).
(* Seemingly, also J3 and/or WG5 discussed this (plenum? subgroups?) and
they had the permit it. However, finding some official document is
difficult.)
I was wondering for a while what should be permitted and what shouldn't,
but I have now decided to put that completely into the hands of the user.
Build and regtested on x86-64-gnu-linux.
OK for the trunk?
Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cbinding-multi-decl.diff
Type: text/x-patch
Size: 23758 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20130517/65551d6b/attachment.bin>
More information about the Fortran
mailing list