xref: /llvm-project/flang/test/Semantics/OpenMP/resolve03.f90 (revision 502bea25bdc07d1811b8bfea1c2e6bfa8617f72f)
1! RUN: %python %S/../test_errors.py %s %flang -fopenmp
2
3! 2.15.3 Although variables in common blocks can be accessed by use association
4! or host association, common block names cannot. As a result, a common block
5! name specified in a data-sharing attribute clause must be declared to be a
6! common block in the same scoping unit in which the data-sharing attribute
7! clause appears.
8
9  common /c/ a, b
10  integer a(3), b
11  common /tc/ x
12  integer x
13  !$omp threadprivate(/tc/)
14
15  A = 1
16  B = 2
17  block
18    !ERROR: COMMON block must be declared in the same scoping unit in which the OpenMP directive or clause appears
19    !$omp parallel shared(/c/)
20    a(1:2) = 3
21    B = 4
22    !$omp end parallel
23  end block
24  print *, a, b
25
26  !$omp parallel
27    block
28      !$omp single
29        x = 18
30      !ERROR: COMMON block must be declared in the same scoping unit in which the OpenMP directive or clause appears
31      !$omp end single copyprivate(/tc/)
32    end block
33  !$omp end parallel
34
35  ! Common block names may be used inside nested OpenMP directives.
36  !$omp parallel
37    !$omp parallel copyin(/tc/)
38      x = x + 10
39    !$omp end parallel
40  !$omp end parallel
41
42  !$omp parallel
43    !$omp single
44      x = 18
45    !$omp end single copyprivate(/tc/)
46  !$omp end parallel
47end
48