Debian Codegraph @

gcc/testsuite/gfortran.dg/pure_formal_proc_4.f90

raw
1 ! { dg-do compile }
2 ! PR fortran/106948 - check that passing of PURE procedures works
3 !
4 ! Contributed by Jim Feng
5
6 module a
7 implicit none
8
9 interface new
10 pure module subroutine b(x, f)
11 integer, intent(inout) :: x
12 interface
13 pure function f(x) result(r)
14 real, intent(in) :: x
15 real :: r
16 end function f
17 end interface
18 end subroutine b
19 end interface new
20 end module a
21
22 submodule(a) a_b
23 implicit none
24
25 contains
26 module procedure b
27 x = int(f(real(x)) * 0.15)
28 end procedure b
29 end submodule a_b
30
31 program test
32 use a
33 implicit none
34
35 integer :: x
36
37 x = 100
38 call new(x, g)
39 print *, x
40
41 contains
42
43 pure function g(y) result(r)
44 real, intent(in) :: y
45 real :: r
46
47 r = sqrt(y)
48 end function g
49 end program test