1! Program to test contained functions calling their siblings.
2! This is tricky because we don't find the declaration for the sibling
3! function until after the caller has been parsed.
4program contained_3
5  call test
6contains
7  subroutine test
8    if (sub(3) .ne. 6) call abort
9  end subroutine
10  integer function sub(i)
11    integer i
12    if (i .gt. 1) then
13      sub = sub2(i) * i
14    else
15      sub = 1
16    end if
17  end function
18  integer function sub2(i)
19    integer i
20    sub2 = sub(i - 1)
21  end function
22end program
23