| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! PR 41139: [4.5 Regression] a procedure pointer call as actual argument |
| 4 |
! |
| 5 |
! Original test case by Barron Bichon <[email protected]> |
| 6 |
! Modified by Janus Weil <[email protected]> |
| 7 |
|
| 8 |
PROGRAM test |
| 9 |
|
| 10 |
PROCEDURE(add), POINTER :: f |
| 11 |
logical :: g |
| 12 |
|
| 13 |
! Passing the function works |
| 14 |
g=greater(4.,add(1.,2.)) |
| 15 |
if (.not. g) STOP 1 |
| 16 |
|
| 17 |
! Passing the procedure pointer fails |
| 18 |
f => add |
| 19 |
g=greater(4.,f(1.,2.)) |
| 20 |
if (.not. g) STOP 2 |
| 21 |
|
| 22 |
CONTAINS |
| 23 |
|
| 24 |
REAL FUNCTION add(x,y) |
| 25 |
REAL, INTENT(in) :: x,y |
| 26 |
print *,"add:",x,y |
| 27 |
add = x+y |
| 28 |
END FUNCTION add |
| 29 |
|
| 30 |
LOGICAL FUNCTION greater(x,y) |
| 31 |
REAL, INTENT(in) :: x, y |
| 32 |
greater = (x > y) |
| 33 |
END FUNCTION greater |
| 34 |
|
| 35 |
END PROGRAM test |
| 36 |
|