[Patch, Fortran] PR32980 - Add GAMMA and LGAMMA intrinsics
Tobias Schlüter
tobias.schlueter@physik.uni-muenchen.de
Tue Aug 21 21:18:00 GMT 2007
Tobias Burnus wrote:
> Tobias SchlÃŒter wrote:
>> I'm worried that this will lead to surprising results for people that
>> have their own GAMMA functions defined. Maybe a new std class is
>> appropriate? What's the opposite of "legacy"? Maybe "incompatible",
>> as in "even incompatible extensions"?
>
> Are you suggest that GAMMA is only available with -std=f2008 and
> -std=incompatible? I would find it extremely surprising if -std=f2003
> and -std=gnu give a different result than -std=f2008! (Not that we have
> Fortran 2008 yet, but it will come rather sooner than later.)
>
> A proper Fortran program already uses "EXTERNAL GAMMA" or better an
> explicit interface for nonintrinsic functions. Additionally, GAMMA is
> present in several other compilers such as IBM lf95, g95 or openf95,
> which thus have the same problem.
>
> (When we have whole-file checks, one should put in a check whether a
> user routine has the same name as an intrinsic procedure when no
> intrinsic or external has been used, in which case a warning should be
> printed.)
Ok, since you and Steve agree on this, I have a suggestion that I think
we all could live with: if the user defines a function that has the same
name as an intrinsic available with the selected standard, issue a
warning, perhaps only with -Wall. Bonus points for a command line
option that allows disabling intrinsics by name.
Thus,
FUNCTION GAMMA(x)
...
END FUNCTION
PRINT *, GAMMA(x)
END
will not call the function the user intended, but at least he will be
able to understand why because the compiler told him something akin to
FUNCTION GAMMA(x)
1
Warning: 'GAMMA' declared at (1) is also the name of an intrinsic. It
can only be called via an explicit interface or if declared EXTERNAL.
If gamma is declared in a module the warning could be something like
Warning: 'GAMMA' declared at (1) may shadow the intrinsic of the same
name. In order to call the intrinsic, explicit INTRINSIC declarations
may be required.
Cheers,
- Tobi
More information about the Fortran
mailing list