Next: Transforming Statements, Previous: Two-pass Design, Up: Front End
Consider the following Fortran code, which uses various extensions (including some to Fortran 90):
SUBROUTINE X(A) CHARACTER*(*) A COMPLEX CFUNC INTEGER*2 CLOCKS(200) INTEGER IFUNC CALL SYSTEM_CLOCK (CLOCKS (IFUNC (CFUNC ('('//A//')'))))
The above poses the following challenges to any Fortran compiler
that uses run-time interfaces, and a run-time library, roughly similar
to those used by g77
:
SYSTEM_CLOCK
expects to set an INTEGER*4
variable via its COUNT
argument,
the compiler must make available to it a temporary variable of that type.
SYSTEM_CLOCK
library routine returns,
the compiler must ensure that the temporary variable it wrote
is copied into the appropriate element of the `CLOCKS' array.
(This assumes the compiler doesn't just reject the code,
which it should if it is compiling under some kind of a “strict” option.)
SYSTEM_CLOCK
library routine returns),
the compiler must ensure that the IFUNC
function is called.
That requires evaluating its argument,
which requires, for g77
(assuming -ff2c
is in force),
reserving a temporary variable of type COMPLEX
for use as a repository for the return value
being computed by `CFUNC'.
CFUNC
should, ideally, be deallocated
(or, at least, left to the GBE to dispose of, as it sees fit)
as soon as CFUNC
returns,
which means before IFUNC
is called
(as it might need a lot of dynamically allocated memory).
g77
currently doesn't support all of the above,
but, so that it might someday, it has evolved to handle
at least some of the above requirements.
Meeting the above requirements is made more challenging by conforming to the requirements of the GBEL/GBE combination.