blob: 296f72fbcca8d72aaba9cb08538b7ad66c658e09 [file] [log] [blame]
! { dg-do run }
! PR 47065 - make sure that impure functions are not evaluated twice when
! replacing calls to trim with expression(1:len_trim)
module foo
implicit none
contains
function f()
integer :: f
integer :: s=0
s = s + 1
f = s
end function f
end module foo
program main
use foo
implicit none
character(len=10) :: line
character(len=4) :: b(2)
b(1) = 'a'
b(2) = 'bc'
write(unit=line,fmt='(A,A)') trim(b(f())), "X"
if (line /= "aX ") STOP 1
if (f() .ne. 2) STOP 2
end program main