| 1 |
! { dg-do compile } |
| 2 |
! |
| 3 |
! Test the fix for pr117434, in which the F2008 addition of being permitted to |
| 4 |
! pass an external, internal or module procedure to a dummy procedure pointer |
| 5 |
! gave the error "Expected a procedure pointer for argument ‘<arg_name>’ at (1). |
| 6 |
! |
| 7 |
! This testcase checks for correct results. |
| 8 |
! |
| 9 |
! Contributed by Damian Rouson <[email protected]> |
| 10 |
! |
| 11 |
module julienne_test_description_m |
| 12 |
implicit none |
| 13 |
|
| 14 |
abstract interface |
| 15 |
logical function test_function_i(arg) |
| 16 |
integer, intent(in) :: arg |
| 17 |
end function |
| 18 |
end interface |
| 19 |
|
| 20 |
type test_description_t |
| 21 |
procedure(test_function_i), pointer, nopass :: test_function_ |
| 22 |
end type |
| 23 |
|
| 24 |
|
| 25 |
contains |
| 26 |
|
| 27 |
type(test_description_t) function new_test_description(test_function) |
| 28 |
procedure(test_function_i), intent(in), pointer :: test_function |
| 29 |
new_test_description%test_function_ => test_function |
| 30 |
end function |
| 31 |
|
| 32 |
end module |
| 33 |
|
| 34 |
module test_mod |
| 35 |
|
| 36 |
contains |
| 37 |
|
| 38 |
logical function mod_test(arg) |
| 39 |
integer, intent(in) :: arg |
| 40 |
if (arg == 1) then |
| 41 |
mod_test = .true. |
| 42 |
else |
| 43 |
mod_test = .false. |
| 44 |
endif |
| 45 |
end function |
| 46 |
|
| 47 |
end |
| 48 |
|
| 49 |
logical function ext_test(arg) |
| 50 |
integer, intent(in) :: arg |
| 51 |
if (arg == 2) then |
| 52 |
ext_test = .true. |
| 53 |
else |
| 54 |
ext_test = .false. |
| 55 |
endif |
| 56 |
end function |
| 57 |
|
| 58 |
use julienne_test_description_m |
| 59 |
use test_mod |
| 60 |
implicit none |
| 61 |
type(test_description_t) test_description |
| 62 |
|
| 63 |
interface |
| 64 |
logical function ext_test(arg) |
| 65 |
integer, intent(in) :: arg |
| 66 |
end function |
| 67 |
end interface |
| 68 |
|
| 69 |
test_description = new_test_description(test) |
| 70 |
if (test_description%test_function_(1) & |
| 71 |
.or. test_description%test_function_(2) & |
| 72 |
.or. .not.test_description%test_function_(3)) stop 1 |
| 73 |
|
| 74 |
test_description = new_test_description(mod_test) |
| 75 |
if (test_description%test_function_(2) & |
| 76 |
.or. test_description%test_function_(3) & |
| 77 |
.or. .not.test_description%test_function_(1)) stop 2 |
| 78 |
|
| 79 |
test_description = new_test_description(ext_test) |
| 80 |
if (test_description%test_function_(1) & |
| 81 |
.or. test_description%test_function_(3) & |
| 82 |
.or. .not.test_description%test_function_(2)) stop 3 |
| 83 |
|
| 84 |
contains |
| 85 |
|
| 86 |
logical function test(arg) |
| 87 |
integer, intent(in) :: arg |
| 88 |
if (arg == 3) then |
| 89 |
test = .true. |
| 90 |
else |
| 91 |
test = .false. |
| 92 |
endif |
| 93 |
end function |
| 94 |
|
| 95 |
end |