On Mon, Jul 07, 2025 at 08:53:16PM +0200, Harald Anlauf wrote:
> Andre,
> 
> I still don't get it, and the present version made it worse for me...
> 
> So let's see what I was thinking.  There are the following types of
> functions:
> 
> (0) impure, non-elemental functions, which likely have side-effects
> 
> (1) pure functions (in the f95 sense), i.e. pure non-elemental
> 
> (2) pure elemental functions (in the f95 sense)
> 
> (3) impure elemental functions (>= f2008)

It's now a bit more complicated.  There are SIMPLE procedures,
but gfortran does not support that prefix yet.

> Note that I understand "pure elemental" being different from
> "pure and elemental" as used in the comment: the first version
> really means both pure and elemental, the second could be read
> as either pure or elemental or pure elemental.  A native speaker
> may correct me if I am wrong...
> 
> Back to gfortran: we have in decl.cc::gfc_match_prefix
> 
>   /* If IMPURE it not seen but the procedure is ELEMENTAL, mark it as PURE.
> */
>   if (!seen_impure && current_attr.elemental && !current_attr.pure)
>     {
>       if (!gfc_add_pure (&current_attr, NULL))
>       goto error;
>     }
> 
> This explains the possible attributes we should see.

The standardese is

  F2023, 15.9 Elemental procedures
  ...

  An elemental subprogram has the prefix-spec ELEMENTAL.  An
  elemental subprogram is a pure subprogram unless it has the
  prefix-spec IMPURE.


I think the rest of your observations/questions are spot-on.

-- 
steve

Reply via email to