aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.fortran/allocate-static.f90
blob: 2789e39e19bb2a761b622af82f40c67e7207e49f (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
module m
  use iso_c_binding, only: c_intptr_t
  use omp_lib_kinds, only: omp_default_mem_alloc
  implicit none (type, external)

  integer(c_intptr_t) :: intptr

  integer :: A(4) = [1,2,3,4]
  !$omp allocate(A) align(128) allocator(omp_default_mem_alloc)
contains
  subroutine f()
    integer :: B(4) = [1,2,3,4]
    !$omp allocate(B) align(256) allocator(omp_default_mem_alloc)

    if (mod (transfer (loc (A), intptr), 128_c_intptr_t) /= 0) stop 1
    if (mod (transfer (loc (B), intptr), 256_c_intptr_t) /= 0) stop 2

    call inner()
  contains
    subroutine inner()
      integer :: C(4) = [1,2,3,4]
      !$omp allocate(C) align(1024) allocator(omp_default_mem_alloc)
      if (mod (transfer (loc (A), intptr), 128_c_intptr_t) /= 0) stop 3
      if (mod (transfer (loc (B), intptr), 256_c_intptr_t) /= 0) stop 4
      if (mod (transfer (loc (C), intptr), 1024_c_intptr_t) /= 0) stop 5
    end
  end
end

use m
implicit none (type, external)
if (mod (transfer (loc (A), intptr), 128_c_intptr_t) /= 0) stop 6
call f()
end