Testers needed for ISO C Binding patch
Tobias Schlüter
tobias.schlueter@physik.uni-muenchen.de
Thu Jun 7 19:01:00 GMT 2007
Christopher D. Rickett wrote:
>>> + /* Initialize the derived type as being C interoperable.
>>> + If we find an error in the components, this will be set false. */
>>> + derived_sym->ts.is_c_interop = 1;
>>> + + /* Loop through the list of components to verify that the kind of
>>> + each is a C interoperable type. */
>>> + do
>>> + {
>>> + /* BIND(C) derived types can't have derived types in them unless
>>> + they're c_ptr or c_funptr. J3/04-007, Section 15.2.3, C1502. */
>>> + if (curr_comp->ts.type == BT_DERIVED
>>> + && curr_comp->ts.derived->ts.is_iso_c != 1)
>>> + {
>>> + /* This should be allowed; the draft says a derived-type
>>> can not
^^^^^^^
cannot, here and elsewhere.
>>> + have type parameters if it is has the BIND attribute.
>>> Type
>>> + parameters seem to be for making parameterized derived
>>> types.
>>> + There's no need to verify the type if it is
>>> c_ptr/c_funptr. */
>>> + retval = verify_bind_c_derived_type (curr_comp->ts.derived);
>>
>> This will break for POINTER components, unless I'm mistaken.
>> type t
>> type (t), pointer :: next
>> end type t
>> -> infinite recursion
>> I also believe this will break for ALLOCATABLE array components --
>> they are not C interoperable, but I don't see it checked here.
>
> i think i've fixed the infinite recursion case. what case are you
> referring to for ALLOCATABLE components?
I don't think the original code would catch something like
TYPE, bind(c) :: t
integer :: i
end type t
type, bind(c):: t2
type(t), allocatable :: c(:)
end type t2
My other suggestion should be able to take care of that (with typos
fixed, sorry, I'm recovering from a disease, which apparently affected
my cognitive abilities :-/):
>> Hm, reading further I realize that you have the appropriate checks,
>> just not in a place where they're performed for derived type
>> components: these two should be moved to the beginning of the loop.
Cheers,
- Tobi
More information about the Fortran
mailing list