| 1 |
! { dg-do link } |
| 2 |
! { dg-additional-options "-fdump-tree-gimple" } |
| 3 |
! { dg-additional-sources "declare-variant-mod-1-use.f90" } |
| 4 |
|
| 5 |
! Note: We have to use 'link' as otherwise '-o' is specified, |
| 6 |
! which does not work with multiple files. |
| 7 |
|
| 8 |
! Check that module-file handling works for declare_variant |
| 9 |
! and its match/adjust_args/append_args clauses |
| 10 |
! |
| 11 |
! PR fortran/115271 |
| 12 |
|
| 13 |
! Define to make linker happy |
| 14 |
integer function m1_f (x, y, z) |
| 15 |
use iso_c_binding |
| 16 |
type(c_ptr) :: x, y, z |
| 17 |
value :: x |
| 18 |
end |
| 19 |
|
| 20 |
integer function m1_g (x, y, z) |
| 21 |
use iso_c_binding |
| 22 |
type(c_ptr) :: x, y, z |
| 23 |
value :: x |
| 24 |
end |
| 25 |
|
| 26 |
module m1 |
| 27 |
implicit none (type, external) |
| 28 |
|
| 29 |
interface |
| 30 |
integer function m1_f (x, y, z) |
| 31 |
use iso_c_binding |
| 32 |
type(c_ptr) :: x, y, z |
| 33 |
value :: x |
| 34 |
end |
| 35 |
integer function m1_g (x, y, z) |
| 36 |
!$omp declare variant(m1_f) match(construct={dispatch}) adjust_args(need_device_ptr: x, 3) adjust_args(nothing: y) |
| 37 |
use iso_c_binding |
| 38 |
type(c_ptr) :: x, y, z |
| 39 |
value :: x |
| 40 |
end |
| 41 |
end interface |
| 42 |
end module m1 |
| 43 |
|
| 44 |
module m2 |
| 45 |
implicit none (type, external) |
| 46 |
contains |
| 47 |
integer function m2_f (x, y, z) |
| 48 |
use iso_c_binding |
| 49 |
type(c_ptr) :: x, y, z |
| 50 |
value :: x |
| 51 |
m2_f = 1 |
| 52 |
end |
| 53 |
integer function m2_g (x, y, z) |
| 54 |
!$omp declare variant(m2_f) match(construct={dispatch}) adjust_args(need_device_ptr: x, 3) adjust_args(nothing: y) |
| 55 |
use iso_c_binding |
| 56 |
type(c_ptr) :: x, y, z |
| 57 |
value :: x |
| 58 |
m2_g = 2 |
| 59 |
end |
| 60 |
end module m2 |
| 61 |
|
| 62 |
module m3_pre |
| 63 |
implicit none (type, external) |
| 64 |
contains |
| 65 |
integer function m3_f (x, y, z) |
| 66 |
use iso_c_binding |
| 67 |
type(c_ptr) :: x, y, z |
| 68 |
value :: x |
| 69 |
m3_f = 1 |
| 70 |
end |
| 71 |
integer function m3_g (x, y, z) |
| 72 |
use iso_c_binding |
| 73 |
type(c_ptr) :: x, y, z |
| 74 |
value :: x |
| 75 |
m3_g = 2 |
| 76 |
end |
| 77 |
end module m3_pre |
| 78 |
|
| 79 |
module m3 |
| 80 |
use m3_pre, only: my_m3_f => m3_f, my_m3_g => m3_g |
| 81 |
implicit none (type, external) |
| 82 |
!$omp declare variant(my_m3_g : my_m3_f) match(construct={dispatch}) adjust_args(need_device_ptr: 1, 3) adjust_args(nothing: 2) |
| 83 |
end module m3 |