Following the fix of pr35837 by Daniel Kraft (thanks for it) I found that it
also fixed a reject-valid bug for the comment #1 in pr29389. In the process
this uncovered an accept-invalid bug as shown by the following modification of
gfortran.dg/stfunc_6.f90:

! { dg-do compile }
! Tests the fix for the second bit of PR29389, in which the
! statement function would not be recognised as not PURE
! when it referenced a procedure that is not PURE.
!
! This is based on stfunc_4.f90 with the statement function made
! impure by a reference to 'v'.
!
! Contributed by Francois-Xavier Coudert <[EMAIL PROTECTED]>

  INTEGER :: st1, i = 99, a(4), q = 6
  st1 (i) = i * i * i 
  st3 (i) = i * v(i)  ! This Ok
  FORALL(i=1:4) a(i) = st1 (i) 
  FORALL(i=1:4) a(i) = u (a(i)) - a(i)** 2 
  if (any (a .ne. 0)) call abort ()
  if (i .ne. 99) call abort ()
  FORALL(i=1:4) a(i) = st3 (i) ! This should give "Error: reference to non-PURE
'v' at (1) is inside a FORALL block"
  FORALL(i=1:4) a(i) = v (i) ! This gives "Error: reference  to non-PURE 'v' at
(1) is inside a FORALL block"
contains
  pure integer function u (x)
    integer,intent(in) :: x
    st2 (i) = i * v(i) ! { dg-error "non-PURE procedure" }
    u = st2(x)
  end function
  integer function v (x)
    integer,intent(in) :: x
    v = i
  end function
end

Since v() is not PURE, st3() is also not PURE and its use in a FORALL construct
should be rejected as it is for v(). Note that the same constraint applies for
the mask. So far I have been unable to see if a similar constraint applies for
WHERE blocks.


-- 
           Summary: Statement functions mask missing PURE procedures.
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dominiq at lps dot ens dot fr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37398

Reply via email to