This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: impure elemental and DECL_PURE_P / TREE_SIDE_EFFECTS?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]