[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / omp-reduction07.f90
blobe1f1d86d6136634d54f0f8ca7bc2dac2ada12c47
1 ! RUN: %S/test_errors.sh %s %t %flang_fc1 -fopenmp
2 ! REQUIRES: shell
3 ! OpenMP Version 4.5
4 ! 2.15.3.6 Reduction Clause
5 program omp_reduction
7 integer :: i,j,l
8 integer :: k = 10
9 !$omp parallel private(k)
10 !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.
11 !$omp do reduction(+:k)
12 do i = 1, 10
13 k = k + 1
14 end do
15 !$omp end do
16 !$omp end parallel
19 !$omp parallel private(j),reduction(-:k)
20 !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.
21 !$omp do reduction(+:k)
22 do i = 1, 10
23 k = k + 1
24 end do
25 !$omp end do
26 !$omp end parallel
28 !$omp parallel private(j),firstprivate(k)
29 !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.
30 !$omp do reduction(min:k)
31 do i = 1, 10
32 k = k + 1
33 end do
34 !$omp end do
35 !$omp end parallel
38 !$omp parallel private(l,j),firstprivate(k)
39 !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.
40 !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.
41 !$omp sections reduction(ior:k) reduction(-:j)
42 do i = 1, 10
43 k = k + 1
44 end do
45 !$omp end sections
46 !$omp end parallel
48 !$omp sections private(k)
49 !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
50 !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.
51 !$omp do reduction(+:k) reduction(max:j)
52 do i = 1, 10
53 k = k + 1
54 end do
55 !$omp end do
56 !$omp end sections
58 !$omp sections private(k)
59 !$omp target
60 do j = 1,10
61 !ERROR: A worksharing region may not be closely nested inside a worksharing, explicit task, taskloop, critical, ordered, atomic, or master region
62 !$omp do reduction(+:k) reduction(max:j)
63 do i = 1, 10
64 k = k + 1
65 end do
66 !$omp end do
67 end do
68 !$omp end target
69 !$omp end sections
71 !$omp parallel reduction(+:a)
72 !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.
73 !$omp sections reduction(-:a)
74 a = 10
75 !$omp end sections
76 !$omp end parallel
78 !$omp parallel reduction(-:a)
79 !$omp end parallel
82 !$omp parallel reduction(+:a)
83 !ERROR: REDUCTION clause is not allowed on the WORKSHARE directive
84 !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.
85 !$omp workshare reduction(-:a)
86 a = 10
87 !$omp end workshare
88 !$omp end parallel
90 !$omp parallel reduction(-:a)
91 !$omp end parallel
94 !$omp parallel reduction(+:a)
95 !ERROR: REDUCTION clause is not allowed on the SINGLE directive
96 !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.
97 !$omp single reduction(-:a)
98 a = 10
99 !$omp end single
100 !$omp end parallel
102 !$omp parallel reduction(-:a)
103 !$omp end parallel
106 !$omp parallel reduction(+:a)
107 !ERROR: REDUCTION clause is not allowed on the SINGLE directive
108 !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.
109 !$omp single reduction(iand:a)
110 a = 10
111 !$omp end single
112 !$omp end parallel
114 !$omp parallel reduction(iand:a)
115 !$omp end parallel
117 !$omp parallel reduction(ieor:a)
118 !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.
119 !$omp sections reduction(-:a)
120 a = 10
121 !$omp end sections
122 !$omp end parallel
124 !$omp parallel reduction(ieor:a)
125 !$omp end parallel
127 end program omp_reduction