This is the mail archive of the
mailing list for the GCC project.
Re: [Patch, Fortran] *PING* -- PR 38160 - C Binding: Kind parameter checking too strict and too late
- From: Tobias Burnus <burnus at net-b dot de>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>, "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>
- Date: Fri, 21 Nov 2008 22:23:30 +0100
- Subject: Re: [Patch, Fortran] *PING* -- PR 38160 - C Binding: Kind parameter checking too strict and too late
- References: <49207D47.firstname.lastname@example.org>
* PING *
Steve suggested to change the gfc_warning to a gfc_error(_now); I think
he is right.
He also suggested to emit a warning when using c_double for complex or
c_double_complex for real variables, but I disagree.
Is the patch (which fixes arguably a reject valid) OK for the trunk (4.4
Tobias Burnus wrote:
> Chris implemented some checking to ensure that one is using the right
> type kind parameter for BIND(C), e.g.
> subroutine foo(x) bind(x)
> real(c_int) :: x
> prints the error:
> subroutine foo(x) bind(C)
> Error: C kind parameter is for type INTEGER but symbol 'x' at (1) is of
> type REAL
> Similarly for
> complex(c_double) :: z
> ptr = c_loc(z)
> The latter is actually what is used in the Fortran bindings for the GNU
> Scientific Library (FGSL). In principle, one should use here
> c_double_complex, but as Steve noticed, the standard explicitly states
> that c_(real) and c_(real)_complex have the same value.
> Changes by the patch:
> a) The diagnostic comes too late, i.e. I expect a message for
> complex(c_int) :: z
> and not for
> Thus I changed this.
> b) complex(c_double) is rejected although the kind type parameter is the
> same as c_double_complex according to the standard.
> c) I downgraded the error for "REAL(C_INT)" to a warning, but I can also
> turn it again into a error; what do you think?
> Build and regtested on x86-64-linux.
> OK for the trunk?