This is the mail archive of the
mailing list for the GNU Fortran project.
Re: [gfortran] Fix PR 20178: Implement g77 / f2c calling conventions
Paul Brook wrote:
>>Can we also agree on -fno-second-underscore as the default?
> I guess so.
> No they aren't.
> The specific versions of intrinsics are generated files written in fortran
> specifically so we don't have to figure out the calling convention. See
> m4/specific*.m4 and the hack in gfc_get_extern_function_decl.
Thanks for pointing this out. I did some preprocessor magic to obtain the
same result, as I didn't want to learn m4.
> We at the tree level we already create a local variable to hold the return
> variable. I imagine the 'proper' fix would be to give this the proper type
> (ie real*4), then just do the conversion in the final "return" statement in
I couldn't see how this can be made to work without breaking the symmetry
between a functions result, and the function itself which is assumed in
several places. So I haven't implemented that in this way.
> Your current implementation is probably ok for now, though a comment would be
Whoops, I forgot adding a comment about this, and the fold_convert is still
required in the actual implementation. I will add a comment before committing
or in the next revision of this patch -- whichever comes sooner.
Attached is an updated version of the patch. Changes from the previous version:
- fno-second-underscore has been made the default and the documentation
- the return type for REAL*4 functions is now set in gfc_get_sym_type, which
- I could largely simplify the checks for when a function had be modified to
accomodate f2c calling conventions, after I had found out that a function
returning an array always require an explicit interface (IOW this isn't
possible in Fortran 77)
- full support for passing intrinsics as actual arguments with -ff2c
This passes the testsuite with no regressions, both with -ff2c enabled or
disabled by default. I didn't manage to add -ff2c to the list of options the
testsuite cycles through, apparently the code in
testsuite/lib/fortran-torture.exp isn't the right place any longer. Ideas?
Ok? I'd also appreciate if people could verify that this is really compatible
with g77, I did some testing, and there should only be three cases (REAL
result, COMPLEX result, DOUBLE COMPLEX result) but maybe I missed something.