view gcc/testsuite/gfortran.dg/recursive_check_11.f90 @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
line wrap: on
line source

! { dg-do run }
! { dg-options "-fcheck=recursion" }
! { dg-shouldfail "Recursion check" }
!
! { dg-output "Fortran runtime error: Recursive call to nonrecursive procedure 'f'" }
!
! PR fortran/39577
!
! wrong - recursion
program test
 integer :: i
 i = f(.false.)
 print *,i
 i = f(.true.)
 print *,i
contains
  integer function f(rec) 
    logical :: rec
    if(rec) then
      f = g()
    else
      f = 42
    end if
  end function f
  integer function g()
    g = f(.false.)
  end function g
end program test