blob: 7ec6ad4c6484d7d86b8371574e34f67d096edd2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
! { dg-do run }
! { dg-options "-std=f2008 -fall-intrinsics" }
! PR fortran/34162
! Internal procedures as actual arguments (like restricted closures).
! Check it works basically.
! Contributed by Daniel Kraft, d@domob.eu.
MODULE m
IMPLICIT NONE
ABSTRACT INTERFACE
FUNCTION returnValue ()
INTEGER :: returnValue
END FUNCTION returnValue
SUBROUTINE doSomething ()
END SUBROUTINE doSomething
END INTERFACE
CONTAINS
FUNCTION callIt (proc)
PROCEDURE(returnValue) :: proc
INTEGER :: callIt
callIt = proc ()
END FUNCTION callIt
SUBROUTINE callSub (proc)
PROCEDURE(doSomething) :: proc
CALL proc ()
END SUBROUTINE callSub
END MODULE m
PROGRAM main
USE :: m
IMPLICIT NONE
INTEGER :: a
a = 42
IF (callIt (myA) /= 42) CALL abort ()
CALL callSub (incA)
IF (a /= 43) CALL abort ()
CONTAINS
FUNCTION myA ()
INTEGER :: myA
myA = a
END FUNCTION myA
SUBROUTINE incA ()
a = a + 1
END SUBROUTINE incA
END PROGRAM main
! { dg-final { cleanup-modules "m" } }
|