xref: /llvm-project/flang/test/Semantics/OpenMP/allocators04.f90 (revision cdbd22876b71acad9e5eeceadc0d8859e6e73b18)
1fb5fd2d8SMichael Klemm! REQUIRES: openmp_runtime
2fb5fd2d8SMichael Klemm
3*cdbd2287SKrzysztof Parzyszek! RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags -fopenmp-version=50
47f0d54b4SEthan Luis McDonough! OpenMP Version 5.2
57f0d54b4SEthan Luis McDonough! Inherited from 2.11.3 allocate Directive
67f0d54b4SEthan Luis McDonough! If list items within the ALLOCATE directive have the SAVE attribute, are a common block name, or are declared in the scope of a
77f0d54b4SEthan Luis McDonough! module, then only predefined memory allocator parameters can be used in the allocator clause
87f0d54b4SEthan Luis McDonough! SAVE and common block names can't be declared as allocatable, only module scope variables are tested
97f0d54b4SEthan Luis McDonough
107f0d54b4SEthan Luis McDonoughmodule AllocateModule
117f0d54b4SEthan Luis McDonough    integer, allocatable :: a, b
127f0d54b4SEthan Luis McDonoughend module
137f0d54b4SEthan Luis McDonough
147f0d54b4SEthan Luis McDonoughsubroutine allocate()
157f0d54b4SEthan Luis McDonough    use omp_lib
167f0d54b4SEthan Luis McDonough    use AllocateModule
177f0d54b4SEthan Luis McDonough
187f0d54b4SEthan Luis McDonough    integer(kind=omp_allocator_handle_kind) :: custom_allocator
197f0d54b4SEthan Luis McDonough    type(omp_alloctrait) :: trait(1)
207f0d54b4SEthan Luis McDonough
217f0d54b4SEthan Luis McDonough    trait(1)%key = fallback
227f0d54b4SEthan Luis McDonough    trait(1)%value = default_mem_fb
237f0d54b4SEthan Luis McDonough    custom_allocator = omp_init_allocator(omp_default_mem_space, 1, trait)
247f0d54b4SEthan Luis McDonough
257f0d54b4SEthan Luis McDonough    !$omp allocators allocate(omp_default_mem_alloc: a)
267f0d54b4SEthan Luis McDonough        allocate(a)
277f0d54b4SEthan Luis McDonough
287f0d54b4SEthan Luis McDonough    !ERROR: If list items within the ALLOCATORS directive have the SAVE attribute, are a common block name, or are declared in the scope of a module, then only predefined memory allocator parameters can be used in the allocator clause
297f0d54b4SEthan Luis McDonough    !$omp allocators allocate(custom_allocator: b)
307f0d54b4SEthan Luis McDonough        allocate(b)
317f0d54b4SEthan Luis McDonoughend subroutine
32