Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / OpenMP / threadprivate02.f90
blob7f6e8dcc8e8abf3798cc7148d8d96ebfaeff85be
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
6 program threadprivate02
7 integer :: arr1(10)
8 common /blk1/ a1
9 real, save :: eq_a, eq_b, eq_c, eq_d
11 !$omp threadprivate(arr1)
13 !$omp threadprivate(/blk1/)
15 !$omp threadprivate(blk1)
17 !ERROR: A variable in a THREADPRIVATE directive cannot be an element of a common block
18 !$omp threadprivate(a1)
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)
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)
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/
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)
39 !$omp threadprivate(arr3)
41 !$omp threadprivate(/blk2/)
43 !ERROR: A variable in a THREADPRIVATE directive cannot be an element of a common block
44 !$omp threadprivate(a2)
46 !$omp threadprivate(/blk3/)
48 !ERROR: A variable in a THREADPRIVATE directive cannot be an element of a common block
49 !$omp threadprivate(a3)
50 end
51 end
53 module mod4
54 integer :: arr4(10)
55 common /blk4/ a4
57 !$omp threadprivate(arr4)
59 !$omp threadprivate(/blk4/)
61 !$omp threadprivate(blk4)
63 !ERROR: A variable in a THREADPRIVATE directive cannot be an element of a common block
64 !$omp threadprivate(a4)
65 end
67 subroutine func5()
68 integer :: arr5(10)
69 common /blk5/ a5
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)
74 !$omp threadprivate(/blk5/)
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)
79 !ERROR: A variable in a THREADPRIVATE directive cannot be an element of a common block
80 !$omp threadprivate(a5)
81 end