Debian Codegraph @

flang/test/Semantics/OpenMP/threadprivate02.f90

raw
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
6 program threadprivate02
7 integer :: arr1(10)
8 common /blk1/ a1
9 real, save :: eq_a, eq_b, eq_c, eq_d
10
11 !$omp threadprivate(arr1)
12
13 !$omp threadprivate(/blk1/)
14
15 !$omp threadprivate(blk1)
16
17 !ERROR: A variable in a THREADPRIVATE directive cannot be an element of a common block
18 !$omp threadprivate(a1)
19
20 equivalence(eq_a, eq_b)
21 !ERROR: A variable in a THREADPRIVATE directive cannot appear in an EQUIVALENCE statement
22 !$omp threadprivate(eq_a)
23
24 !ERROR: A variable in a THREADPRIVATE directive cannot appear in an EQUIVALENCE statement
25 !$omp threadprivate(eq_c)
26 equivalence(eq_c, eq_d)
27
28 contains
29 subroutine func()
30 integer :: arr2(10)
31 integer, save :: arr3(10)
32 common /blk2/ a2
33 common /blk3/ a3
34 save /blk3/
35
36 !ERROR: A variable that appears in a THREADPRIVATE directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
37 !$omp threadprivate(arr2)
38
39 !$omp threadprivate(arr3)
40
41 !$omp threadprivate(/blk2/)
42
43 !ERROR: A variable in a THREADPRIVATE directive cannot be an element of a common block
44 !$omp threadprivate(a2)
45
46 !$omp threadprivate(/blk3/)
47
48 !ERROR: A variable in a THREADPRIVATE directive cannot be an element of a common block
49 !$omp threadprivate(a3)
50 end
51 end
52
53 module mod4
54 integer :: arr4(10)
55 common /blk4/ a4
56
57 !$omp threadprivate(arr4)
58
59 !$omp threadprivate(/blk4/)
60
61 !$omp threadprivate(blk4)
62
63 !ERROR: A variable in a THREADPRIVATE directive cannot be an element of a common block
64 !$omp threadprivate(a4)
65 end
66
67 subroutine func5()
68 integer :: arr5(10)
69 common /blk5/ a5
70
71 !ERROR: A variable that appears in a THREADPRIVATE directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
72 !$omp threadprivate(arr5)
73
74 !$omp threadprivate(/blk5/)
75
76 !ERROR: A variable that appears in a THREADPRIVATE directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
77 !$omp threadprivate(blk5)
78
79 !ERROR: A variable in a THREADPRIVATE directive cannot be an element of a common block
80 !$omp threadprivate(a5)
81 end