xref: /llvm-project/flang/test/Semantics/OpenMP/threadprivate05.f90 (revision 9f0e59f3c1a56fd14025df973c9f944010efe09a)
1! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
2! OpenMP Version 5.1
3! Check OpenMP construct validity for the following directives:
4! 2.21.2 Threadprivate Directive
5
6module mod0
7  integer :: mi
8
9contains
10  subroutine subm()
11    integer, save :: mmi
12
13    !ERROR: The THREADPRIVATE directive and the common block or variable in it must appear in the same declaration section of a scoping unit
14    !$omp threadprivate(mi)
15    mi = 1
16  contains
17    subroutine subsubm()
18      !ERROR: The THREADPRIVATE directive and the common block or variable in it must appear in the same declaration section of a scoping unit
19      !$omp threadprivate(mmi)
20    end
21  end
22end
23
24module mod1
25  integer :: mod_i
26end
27
28program main
29  use mod1
30  integer, save :: i
31  integer :: j
32
33  !ERROR: The THREADPRIVATE directive and the common block or variable in it must appear in the same declaration section of a scoping unit
34  !$omp threadprivate(mod_i)
35
36contains
37  subroutine sub()
38    !ERROR: The THREADPRIVATE directive and the common block or variable in it must appear in the same declaration section of a scoping unit
39    !ERROR: The THREADPRIVATE directive and the common block or variable in it must appear in the same declaration section of a scoping unit
40    !$omp threadprivate(i, j)
41    i = 1
42    j = 1
43  end
44end
45