This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: impure elemental and DECL_PURE_P / TREE_SIDE_EFFECTS?
- From: Mikael Morin <mikael dot morin at sfr dot fr>
- To: fortran at gcc dot gnu dot org
- Cc: Thomas Koenig <tkoenig at netcologne dot de>
- Date: Sun, 17 Apr 2011 20:16:42 +0200
- Subject: Re: impure elemental and DECL_PURE_P / TREE_SIDE_EFFECTS?
- References: <4DA9FB48.80805@netcologne.de>
On Saturday 16 April 2011 22:25:44 Thomas Koenig wrote:
> Hello world,
>
> I am looking at trans-decl.c at the moment, and see the following code
> there:
>
> /* Set attributes for PURE functions. A call to a PURE function in the
> Fortran 95 sense is both pure and without side effects in the C
> sense. */
> if (attr.pure || attr.elemental)
> {
> /* TODO: check if a pure SUBROUTINE has no INTENT(OUT) arguments
> including an alternate return. In that case it can also be
> marked as PURE. See also in gfc_get_extern_function_decl(). */
> if (attr.function && !gfc_return_by_reference (sym))
> DECL_PURE_P (fndecl) = 1;
> TREE_SIDE_EFFECTS (fndecl) = 0;
> }
>
> Is this still valid, given that Fortran 2008 has added impure elemental
> functions?
I think it's not. attr.pure should be enough as it is automatically set (see
decl.c, look for seen_impure) in the elemental case.
> And could this be extended to implicitly pure functions?
I think so, but to be tested. ;-)
>
> Thomas
Mikael