1 ! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
3 ! 2.15.3.4 firstprivate Clause
4 ! Variables that appear in a firstprivate clause on a distribute or
5 ! worksharing constructs must not appear in the private or
6 ! reduction clause in a teams or parallel constructs in the outer context
8 ! A list item may appear in a firstprivate or lastprivate clause but not both on
9 ! a distribute directive
11 program omp_firstprivate
12 integer :: i
, a(10), b(10), c(10)
17 !ERROR: TARGET construct with nested TEAMS region contains statements or directives outside of the TEAMS construct
19 !$omp teams private(a, b)
20 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
21 !$omp distribute firstprivate(a)
23 a(i
) = a(i
) + b(i
) - i
27 !$omp teams reduction(+:a)
28 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
29 !$omp distribute firstprivate(a)
31 b(i
) = b(i
) + a(i
) + i
36 !$omp teams distribute firstprivate(a) lastprivate(b)
38 a(i
) = a(i
) + b(i
) - i
40 !$omp end teams distribute
41 !ERROR: Variable 'b' may not appear on both FIRSTPRIVATE and LASTPRIVATE clauses on a TEAMS DISTRIBUTE construct
42 !$omp teams distribute firstprivate(a,b) lastprivate(b)
44 a(i
) = a(i
) + b(i
) - i
46 !$omp end teams distribute
47 !ERROR: Variable 'a' may not appear on both FIRSTPRIVATE and LASTPRIVATE clauses on a TEAMS DISTRIBUTE construct
48 !ERROR: Variable 'b' may not appear on both FIRSTPRIVATE and LASTPRIVATE clauses on a TEAMS DISTRIBUTE construct
49 !$omp teams distribute firstprivate(a,b) lastprivate(a,b)
51 a(i
) = a(i
) + b(i
) - i
53 !$omp end teams distribute
54 !ERROR: Variable 'b' may not appear on both FIRSTPRIVATE and LASTPRIVATE clauses on a TEAMS DISTRIBUTE construct
55 !$omp teams distribute lastprivate(a,b) firstprivate(b)
57 a(i
) = a(i
) + b(i
) - i
59 !$omp end teams distribute
60 !ERROR: Variable 'b' may not appear on both FIRSTPRIVATE and LASTPRIVATE clauses on a TEAMS DISTRIBUTE construct
61 !ERROR: Variable 'a' may not appear on both FIRSTPRIVATE and LASTPRIVATE clauses on a TEAMS DISTRIBUTE construct
62 !$omp teams distribute lastprivate(a,b) firstprivate(b,a)
64 a(i
) = a(i
) + b(i
) - i
66 !$omp end teams distribute
71 !$omp parallel private(a,b)
72 !ERROR: FIRSTPRIVATE variable 'b' is PRIVATE in outer context
73 !$omp do firstprivate(b)
75 c(i
) = a(i
) + b(i
) + i
80 !$omp parallel reduction(*:a)
81 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
82 !$omp do firstprivate(a,b)
84 c(i
) = c(i
) * a(i
) * b(i
) * i
89 !$omp parallel reduction(+:a)
90 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
91 !$omp sections firstprivate(a, b)
97 !$omp parallel reduction(*:a)
98 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
99 !$omp task firstprivate(a,b)
104 !$omp parallel reduction(+:b)
105 !ERROR: FIRSTPRIVATE variable 'b' is PRIVATE in outer context
106 !$omp taskloop firstprivate(b)
108 c(i
) = a(i
) + b(i
) + i
115 !$omp parallel firstprivate(a)
116 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
117 !$omp single firstprivate(a)
124 end program omp_firstprivate