| 1 |
! { dg-additional-options "-fcoarray=single -fcray-pointer" } |
| 2 |
|
| 3 |
module m |
| 4 |
use iso_c_binding |
| 5 |
integer, parameter :: omp_allocator_handle_kind = c_intptr_t |
| 6 |
integer (kind=omp_allocator_handle_kind), & |
| 7 |
parameter :: omp_null_allocator = 0 |
| 8 |
integer (kind=omp_allocator_handle_kind), & |
| 9 |
parameter :: omp_default_mem_alloc = 1 |
| 10 |
integer (kind=omp_allocator_handle_kind), & |
| 11 |
parameter :: omp_large_cap_mem_alloc = 2 |
| 12 |
integer (kind=omp_allocator_handle_kind), & |
| 13 |
parameter :: omp_const_mem_alloc = 3 |
| 14 |
integer (kind=omp_allocator_handle_kind), & |
| 15 |
parameter :: omp_high_bw_mem_alloc = 4 |
| 16 |
integer (kind=omp_allocator_handle_kind), & |
| 17 |
parameter :: omp_low_lat_mem_alloc = 5 |
| 18 |
integer (kind=omp_allocator_handle_kind), & |
| 19 |
parameter :: omp_cgroup_mem_alloc = 6 |
| 20 |
integer (kind=omp_allocator_handle_kind), & |
| 21 |
parameter :: omp_pteam_mem_alloc = 7 |
| 22 |
integer (kind=omp_allocator_handle_kind), & |
| 23 |
parameter :: omp_thread_mem_alloc = 8 |
| 24 |
end |
| 25 |
|
| 26 |
subroutine coarrays(x) |
| 27 |
use m |
| 28 |
implicit none |
| 29 |
|
| 30 |
integer :: x[*] |
| 31 |
integer, allocatable :: y[:], z(:)[:] |
| 32 |
|
| 33 |
!$omp allocate(x) ! { dg-error "Unexpected dummy argument 'x' as argument at .1. to declarative !.OMP ALLOCATE" } |
| 34 |
|
| 35 |
!$omp allocators allocate(y) ! { dg-error "29:Unexpected coarray 'y' in 'allocate' at .1." } |
| 36 |
allocate(y[*]) |
| 37 |
|
| 38 |
!$omp allocate(z) ! { dg-error "18:Unexpected coarray 'z' in 'allocate' at .1." } |
| 39 |
allocate(z(5)[*]) |
| 40 |
x = 5 |
| 41 |
end |
| 42 |
|
| 43 |
|
| 44 |
integer function f() result(res) |
| 45 |
!$omp allocate(f) ! { dg-error "Argument 'f' at .1. to declarative !.OMP ALLOCATE directive must be a variable" } |
| 46 |
!$omp allocate(res) ! { dg-error "Unexpected function-result variable 'res' at .1. in declarative !.OMP ALLOCATE" } |
| 47 |
res = 5 |
| 48 |
end |
| 49 |
|
| 50 |
integer function g() result(res) |
| 51 |
allocatable :: res |
| 52 |
!$omp allocators allocate(g) ! { dg-error "Expected variable list at .1." } |
| 53 |
|
| 54 |
!$omp allocators allocate (res) |
| 55 |
allocate(res, source=5) |
| 56 |
deallocate(res) |
| 57 |
|
| 58 |
!$omp allocate (res) |
| 59 |
allocate(res, source=5) |
| 60 |
end |
| 61 |
|
| 62 |
|
| 63 |
subroutine cray_ptr() |
| 64 |
real pointee(10) |
| 65 |
pointer (ipt, pointee) |
| 66 |
!$omp allocate(pointee) ! { dg-error "Sorry, Cray pointers and pointees such as 'pointee' are not supported with !.OMP ALLOCATE at .1." } |
| 67 |
!$omp allocate(ipt) ! { dg-error "Sorry, Cray pointers and pointees such as 'ipt' are not supported with !.OMP ALLOCATE at .1." } |
| 68 |
end |
| 69 |
|
| 70 |
subroutine equiv |
| 71 |
integer :: A |
| 72 |
real :: B(2) |
| 73 |
equivalence(A,B) |
| 74 |
!$omp allocate (A) ! { dg-error "Sorry, EQUIVALENCE object 'a' not supported with !.OMP ALLOCATE at .1." } |
| 75 |
!$omp allocate (B) ! { dg-error "Sorry, EQUIVALENCE object 'b' not supported with !.OMP ALLOCATE at .1." } |
| 76 |
end |
| 77 |
|
| 78 |
subroutine common |
| 79 |
use m |
| 80 |
integer :: a,b,c(5) |
| 81 |
common /my/ a,b,c |
| 82 |
!$omp allocate(b) allocator(omp_cgroup_mem_alloc) ! { dg-error "'b' at .1. is part of the common block '/my/' and may only be specificed implicitly via the named common block" } |
| 83 |
end |
| 84 |
|
| 85 |
subroutine c_and_func_ptrs |
| 86 |
use iso_c_binding |
| 87 |
implicit none |
| 88 |
procedure(), pointer :: p |
| 89 |
type(c_ptr) :: cptr |
| 90 |
type(c_ptr) :: cfunptr |
| 91 |
|
| 92 |
!$omp allocate(cptr) ! OK |
| 93 |
!$omp allocate(cfunptr) ! OK? A normal derived-type var? |
| 94 |
!$omp allocate(p) ! { dg-error "Argument 'p' at .1. to declarative !.OMP ALLOCATE directive must be a variable" } |
| 95 |
end |
| 96 |
|
| 97 |
|
| 98 |
subroutine coarray_2 |
| 99 |
use m |
| 100 |
implicit none |
| 101 |
integer :: x |
| 102 |
integer, allocatable :: a, b, c[:], d |
| 103 |
x = 5 ! executable stmt |
| 104 |
!$omp allocate(a,b) align(16) |
| 105 |
!$omp allocate ! { dg-error "Unexpected coarray 'c' in 'allocate' at .1., implicitly listed in '!.OMP ALLOCATE' at .2." } |
| 106 |
!$omp allocate(d) align(32) |
| 107 |
allocate(a,b,c[*],d) ! { dg-error "Unexpected coarray 'c' in 'allocate' at .1., implicitly listed in '!.OMP ALLOCATE' at .2." } |
| 108 |
end |
| 109 |
|
| 110 |
|
| 111 |
subroutine coarray_3 |
| 112 |
use m |
| 113 |
implicit none |
| 114 |
integer :: x |
| 115 |
integer, allocatable :: a, b, c[:], d |
| 116 |
x = 5 ! executable stmt |
| 117 |
!$omp allocators allocate(align(16): a,b) allocate(align(32) : d) |
| 118 |
allocate(a,b,c[*],d) ! OK - Fortran allocator used for 'C' |
| 119 |
end |
| 120 |
|
| 121 |
|
| 122 |
subroutine unclear |
| 123 |
use m |
| 124 |
implicit none |
| 125 |
integer :: x |
| 126 |
integer, allocatable :: a, b, c[:], d |
| 127 |
|
| 128 |
! OpenMP is unclear which allocator is used for 'C' - the fortran one or the OpenMP one. |
| 129 |
! GCC therefore rejects it. |
| 130 |
|
| 131 |
x = 5 ! executable stmt |
| 132 |
|
| 133 |
!$omp allocate(a,b) align(16) |
| 134 |
!$omp allocate(d) align(32) |
| 135 |
allocate(a,b,c[*],d) ! { dg-error "'c' listed in 'allocate' statement at .1. but it is neither explicitly in listed in the '!.OMP ALLOCATE' directive nor exists a directive without argument list" } |
| 136 |
end |