PROCEDURE declarations
Tobias Burnus
burnus@net-b.de
Thu Aug 23 04:26:00 GMT 2007
Janus Weil wrote:
> integer function p5()
> p5 =8
> end function
>
> program p
> implicit none
> procedure(real):: p5
>
> The procedure p5 illustrates what I mean: It is declared as real, but
> its actual implementation returns an integer.
Well, in principle the compiler cannot know it. You have a function
somewhere (can be in the same file, can be a compiled .o file) and
completely separately you have a program were you call that function.
How should the compiler know that they clash? Contrary to C each block
is completely separate in Fortran. (If they weren't "procedure ( real )
:: p5" would clash with the "function p5" earlier in that file; this is
also the reason why Fortran 90's modules and host-associated procedures
are that great.)
Granted, good compilers still detect this (if both blocks are in the
same file or if one instructs the compiler to generate mod files for
such procedures), but gfortran does not have this yet. (The same-file
checking is planned though.)
> Should I make any attempt to check matching types in cases like this?
> And is it even possible?
>
It is possible, but it should be done with the general whole-file checking.
> and also includes my recent bugfixes for abstract interfaces.
> I will post some more testcases for the patch soon.
... which are already checked in ;-)
gfc_match_procedure:
+ gfc_error ("BIND(C) attribute requires interface with BIND(C) at
%C");
I think this should be "requires an interface"
Tobias
More information about the Fortran
mailing list