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 program omp_firstprivate
9 integer :: i
, a(10), b(10), c(10)
14 !ERROR: TARGET construct with nested TEAMS region contains statements or directives outside of the TEAMS construct
16 !$omp teams private(a, b)
17 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
18 !$omp distribute firstprivate(a)
20 a(i
) = a(i
) + b(i
) - i
24 !$omp teams reduction(+:a)
25 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
26 !$omp distribute firstprivate(a)
28 b(i
) = b(i
) + a(i
) + i
36 !$omp parallel private(a,b)
37 !ERROR: FIRSTPRIVATE variable 'b' is PRIVATE in outer context
38 !$omp do firstprivate(b)
40 c(i
) = a(i
) + b(i
) + i
45 !$omp parallel reduction(*:a)
46 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
47 !$omp do firstprivate(a,b)
49 c(i
) = c(i
) * a(i
) * b(i
) * i
54 !$omp parallel reduction(+:a)
55 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
56 !$omp sections firstprivate(a, b)
62 !$omp parallel reduction(*:a)
63 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
64 !$omp task firstprivate(a,b)
69 !$omp parallel reduction(+:b)
70 !ERROR: FIRSTPRIVATE variable 'b' is PRIVATE in outer context
71 !$omp taskloop firstprivate(b)
73 c(i
) = a(i
) + b(i
) + i
80 !$omp parallel firstprivate(a)
81 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
82 !$omp single firstprivate(a)
89 end program omp_firstprivate