https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117765

--- Comment #10 from kargls at comcast dot net ---
On 11/25/24 09:50, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117765
> 
> --- Comment #7 from anlauf at gcc dot gnu.org ---
> The patch catches functions but misses subroutine calls, as in:
> 
> ! { dg-do compile }
> !
> program foo
> 
>     implicit none
> 
>     integer i
>     integer :: j = 0
>     real y(4)
> 
>     do concurrent(i=1:4)
>        y(i) = bar(i)        ! { dg-error "Reference to impure function" }
>        call bla(i)      ! <<< caught
>     end do
> 
>     do concurrent(i=1:4)
>        block
>           y(i) = bar(i)     ! { dg-error "Reference to impure function" }
>           call bla(i)   ! <<< MISSED!
>        end block
>     end do
> 
>     contains
> 
>        impure function bar(i)
>           real bar
>           integer, intent(in) :: i
>           j = j + i
>           bar = j
>        end function bar
> 
>        impure subroutine bla (j)
>           integer, intent(in) :: j
>           print *, j
>        end subroutine bla
> 
> end program foo
> 
> 
> If possible, can we fix that, too?
> 

The attached patch now catches the impure subroutine calls.
I have updated the testcase to include tests for calls.

2024-11-26  Steven G. Kargl  <kar...@comcast.net>

        * resolve.cc (pure_subroutine):  Check for an impure subroutine
        call in a BLOCK construct nested within a DO CONCURRENT block.


2024-11-25  Steven G. Kargl  <kar...@comcast.net>

         PR fortran/117765
         * gfortran.dg/impure_fcn_do_concurrent.f90: Update test to catch
        calls to an impure subroutine.

Reply via email to