[WebAssembly] Fix asan issue from https://reviews.llvm.org/D121349
[llvm-project.git] / flang / test / Semantics / omp-reduction07.f90
blob74178a9f39ccbdc576f690cc85d020e969c04716
1 ! RUN: %python %S/test_errors.py %s %flang_fc1 -fopenmp
2 ! OpenMP Version 4.5
3 ! 2.15.3.6 Reduction Clause
4 program omp_reduction
6 integer :: i,j,l
7 integer :: k = 10
8 !$omp parallel private(k)
9 !ERROR: REDUCTION variable 'k' is PRIVATE in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
10 !$omp do reduction(+:k)
11 do i = 1, 10
12 k = k + 1
13 end do
14 !$omp end do
15 !$omp end parallel
18 !$omp parallel private(j),reduction(-:k)
19 !ERROR: REDUCTION variable 'k' is REDUCTION in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
20 !$omp do reduction(+:k)
21 do i = 1, 10
22 k = k + 1
23 end do
24 !$omp end do
25 !$omp end parallel
27 !$omp parallel private(j),firstprivate(k)
28 !ERROR: REDUCTION variable 'k' is FIRSTPRIVATE in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
29 !$omp do reduction(min:k)
30 do i = 1, 10
31 k = k + 1
32 end do
33 !$omp end do
34 !$omp end parallel
37 !$omp parallel private(l,j),firstprivate(k)
38 !ERROR: REDUCTION variable 'k' is FIRSTPRIVATE in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
39 !ERROR: REDUCTION variable 'j' is PRIVATE in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
40 !$omp sections reduction(ior:k) reduction(-:j)
41 do i = 1, 10
42 k = k + 1
43 end do
44 !$omp end sections
45 !$omp end parallel
47 !$omp sections private(k)
48 !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
49 !ERROR: REDUCTION variable 'k' is PRIVATE in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
50 !$omp do reduction(+:k) reduction(max:j)
51 do i = 1, 10
52 k = k + 1
53 end do
54 !$omp end do
55 !$omp end sections
57 !$omp sections private(k)
58 !$omp target
59 do j = 1,10
60 !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
61 !$omp do reduction(+:k) reduction(max:j)
62 do i = 1, 10
63 k = k + 1
64 end do
65 !$omp end do
66 end do
67 !$omp end target
68 !$omp end sections
70 !$omp parallel reduction(+:a)
71 !ERROR: REDUCTION variable 'a' is REDUCTION in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
72 !$omp sections reduction(-:a)
73 a = 10
74 !$omp end sections
75 !$omp end parallel
77 !$omp parallel reduction(-:a)
78 !$omp end parallel
81 !$omp parallel reduction(+:a)
82 !ERROR: REDUCTION clause is not allowed on the WORKSHARE directive
83 !ERROR: REDUCTION variable 'a' is REDUCTION in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
84 !$omp workshare reduction(-:a)
85 a = 10
86 !$omp end workshare
87 !$omp end parallel
89 !$omp parallel reduction(-:a)
90 !$omp end parallel
93 !$omp parallel reduction(+:a)
94 !ERROR: REDUCTION clause is not allowed on the SINGLE directive
95 !ERROR: REDUCTION variable 'a' is REDUCTION in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
96 !$omp single reduction(-:a)
97 a = 10
98 !$omp end single
99 !$omp end parallel
101 !$omp parallel reduction(-:a)
102 !$omp end parallel
105 !$omp parallel reduction(+:a)
106 !ERROR: REDUCTION clause is not allowed on the SINGLE directive
107 !ERROR: REDUCTION variable 'a' is REDUCTION in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
108 !$omp single reduction(iand:a)
109 a = 10
110 !$omp end single
111 !$omp end parallel
113 !$omp parallel reduction(iand:a)
114 !$omp end parallel
116 !$omp parallel reduction(ieor:a)
117 !ERROR: REDUCTION variable 'a' is REDUCTION in outer context must be shared in the parallel regions to which any of the worksharing regions arising from the worksharing construct bind.
118 !$omp sections reduction(-:a)
119 a = 10
120 !$omp end sections
121 !$omp end parallel
123 !$omp parallel reduction(ieor:a)
124 !$omp end parallel
126 end program omp_reduction