<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/118610>118610</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Allow elemental functions in Fortran REDUCE intrinsic function
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ivan-pi
      </td>
    </tr>
</table>

<pre>
    Flang 20.0.0 does not allow elemental functions in the `REDUCE` function:
```fortran
real :: c(3), res
c = [1,2,3]
res = reduce(c,operation=my_add1) ! works
print *, res
res = reduce(c,operation=my_add2) ! error: Non-intrinsic ELEMENTAL procedure ...
print *, res
contains
    pure real function my_add1(a,b)
 real, intent(in) :: a, b
        my_add = a + b
    end function
 elemental real function my_add2(a,b)
        real, intent(in) :: a, b
 my_add = a + b
    end function
end 
```

According to J2/24-007, section 16.9.173, the operation should be a pure function. According to section 15.7 this means it could be a function with prefix-spec `PURE`, `SIMPLE`, or `ELEMENTAL` (but no `IMPURE`).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVE2P4zYM_TX0hYgh044TH3zw5APYYmax2HbPhSwxiVpHMiR5pvvvCzkTZ1ssFiMYsCRSj0_UI2UI5myZW1g_wXqfySlenG_Nq7Sr0WS909_b4yDtGUnkIheoHQe0LqIcBveGPPCVbZQDniaronE2oLEYL4xQi6-H_bfdAWqxWKHsQHRQi9t3cj56aUF0nuWAyVp2qIC2JVADtEPPAUSnEMo9wvqpANoR0K6E9X4-FWaLZz0pBtoqoJ0b2ctbsP31-59S6wKoQaAC35z_O-GN3tiIQN0jxAeh6A7F3juf2H52dmVs9MYGo_DwfHg5fP6je8bRO8V68ox5nv88pnI2SmPTFBFxTM5zIu7pwoX_VgLt-pQU0c0-CcXYyDYCbY2dad3Slzyxf8dM4wYy304i0NNiZKsfLyO6H17zZyzofyzex0fJfJRFWv6okTQXXaeU89rYM0aHvxHQkaqVEJsEH_hGs6jzJi82ZdpLClxeD8PFTYPGnlHesnyPl-N_gBekdb7BeDEBryyTpCOqB8KSlzcTLzh6Ppl_VmFklTT_5dvXpPjEAWrx-6eXL8_3tfNpa1FIqgugbT9FtC5ZPr0sh5s8022pm7KRGbfFpixLUW9FlV3addWIsmaWoha1pkL0ourXrEWl5KYXOjMtCaoKElUhRF1V-bpW20qfqo08NbpvCCrBV2mGfBher7nz58yEMHFbFNu6ENkgex7C3BGILL_hbAWi1CB8mw6t-ukcoBKDCTE8YKKJA7fdrzrD8VbxeGsN-Cicu1c2-aG9xDiGpCA6Ah3PJl6mPlfuCnRMwd5_q9G7v1hFoONMMQAd3-_w2tK_AQAA__9t4nm4">