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

--- Comment #1 from kargl at gcc dot gnu.org ---
F2018 introduced the NON_RECURSIVE prefix for procedures and also made
procedures recursive by default.  This code is conforming to F2018.

module bah

   contains
      !
      ! non_recursive is F2018.
      !
      non_recursive function foo(i) result(k)
         integer k
         integer, intent(in) :: i
         k = i
      end function foo
      !
      ! Recursive has been around for awhile, and still in F2018
      !
      recursive function fib1(i) result(k)
         integer k
         integer, intent(in) :: i
         if (i <= 1) then
            k = i
         else
            k = fib1(i-1) + fib1(i - 2)
         end if
      end function fib1
      !
      ! This is recursive by default.
      !
      function fib2(i) result(k)
         integer k
         integer, intent(in) :: i
         if (i <= 1) then
            k = i
         else
            k = fib2(i-1) + fib2(i - 2)
         end if
      end function fib2

end module bah

program bar
   use bah
   integer i
   i = 9
   print *, fib1(i), fib2(i)
end program bar

Reply via email to