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]

Re: [Patch, Fortran] *PING* -- PR 38160 - C Binding: Kind parameter checking too strict and too late


* PING *

See: http://gcc.gnu.org/ml/fortran/2008-11/msg00194.html

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
or 4.5)?

Tobias



Tobias Burnus wrote:
> Hello,
>
> 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)
>                1
> 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
>    c_loc(z)
> 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?
>
> Tobias
>   


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