Fortran · 482 bytes Raw Blame History
1 ! Host association threaded into a contained FUNCTION (not just
2 ! SUBROUTINE) when the host var is an ARRAY. Tests that the
3 ! closure-passing ABI handles arrays through a function-result
4 ! signature where the function's hidden host-ref params trail
5 ! the normal positional args.
6 ! CHECK: 60
7 program t
8 implicit none
9 integer :: data(3)
10 data = [10, 20, 30]
11 print *, total()
12 contains
13 integer function total()
14 total = data(1) + data(2) + data(3)
15 end function
16 end program
17