Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / OpenMP / reduction07.f90
blob98ed69a8d846d43159d5cab614099cb22866810d
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 :: a,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 = ior(k, 1)
43 j = j * 3
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 = a + 10
75 !$omp end sections
76 !$omp end parallel
78 !$omp parallel reduction(*:a)
79 !$omp end parallel
81 !$omp parallel reduction(ieor:a)
82 !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.
83 !$omp sections reduction(+:a)
84 a = ieor(a, 10)
85 !$omp end sections
86 !$omp end parallel
88 !$omp parallel private(a)
89 !$omp parallel reduction(ieor:a)
90 !$omp end parallel
91 !$omp end parallel
93 !$omp task firstprivate(a)
94 !$omp parallel do reduction(+:a)
95 do i=1,10
96 a=a+j
97 end do
98 !$omp end parallel do
99 !$omp end task
101 end program omp_reduction