xref: /llvm-project/flang/test/Semantics/OpenMP/resolve06.f90 (revision cdbd22876b71acad9e5eeceadc0d8859e6e73b18)
1! REQUIRES: openmp_runtime
2
3! RUN: %python %S/../test_errors.py %s %flang_fc1 %openmp_flags -fopenmp-version=50
4use omp_lib
5!2.11.4 Allocate Clause
6!For any list item that is specified in the allocate
7!clause on a directive, a data-sharing attribute clause
8!that may create a private copy of that list item must be
9!specified on the same directive.
10
11  integer ::  N = 2
12
13  !ERROR: The ALLOCATE clause requires that 'x' must be listed in a private data-sharing attribute clause on the same directive
14  !$omp parallel allocate(omp_default_mem_space : x)
15  do i = 1, N
16     x = 2
17  enddo
18  !$omp end parallel
19
20  !ERROR: The ALLOCATE clause requires that 'y' must be listed in a private data-sharing attribute clause on the same directive
21  !$omp parallel allocate(omp_default_mem_space : y) firstprivate(x)
22  do i = 1, N
23     x = 2
24  enddo
25  !$omp end parallel
26
27  !ERROR: The ALLOCATE clause requires that 'x' must be listed in a private data-sharing attribute clause on the same directive
28  !ERROR: The ALLOCATE clause requires that 'x' must be listed in a private data-sharing attribute clause on the same directive
29  !$omp parallel allocate(omp_default_mem_space : x) allocate(omp_default_mem_space : x)
30  do i = 1, N
31     x = 2
32  enddo
33  !$omp end parallel
34
35  !ERROR: The ALLOCATE clause requires that 'f' must be listed in a private data-sharing attribute clause on the same directive
36  !$omp parallel allocate(omp_default_mem_space : f) shared(f)
37  do i = 1, N
38     x = 2
39  enddo
40  !$omp end parallel
41
42  !ERROR: The ALLOCATE clause requires that 'q' must be listed in a private data-sharing attribute clause on the same directive
43  !$omp parallel private(t) allocate(omp_default_mem_space : z, t, q, r) firstprivate(z, r)
44  do i = 1, N
45     x = 2
46  enddo
47  !$omp end parallel
48
49  !ERROR: The ALLOCATE clause requires that 'b' must be listed in a private data-sharing attribute clause on the same directive
50  !ERROR: The ALLOCATE clause requires that 'c' must be listed in a private data-sharing attribute clause on the same directive
51  !$omp parallel allocate(omp_default_mem_space : a, b, c, d) firstprivate(a, d)
52  do i = 1, N
53     x = 2
54  enddo
55  !$omp end parallel
56end
57