xref: /llvm-project/flang/test/Semantics/OpenMP/lastprivate02.f90 (revision 502bea25bdc07d1811b8bfea1c2e6bfa8617f72f)
1! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
2! OpenMP Version 4.5
3! 2.15.3.5 lastprivate Clause
4! A list item that is private within a parallel region, or that appears in
5! reduction clause of a parallel construct, must not appear in a
6! lastprivate clause on a worksharing construct if any of the corresponding
7! worksharing regions ever binds to any of the corresponding parallel regions.
8
9program omp_lastprivate
10  integer :: a(10), b(10), c(10)
11
12  a = 10
13  b = 20
14
15  !$omp parallel reduction(+:a)
16  !ERROR: LASTPRIVATE variable 'a' is PRIVATE in outer context
17  !$omp sections lastprivate(a, b)
18  !$omp section
19  c = a + b
20  !$omp end sections
21  !$omp end parallel
22
23  !$omp parallel private(a,b)
24  !ERROR: LASTPRIVATE variable 'a' is PRIVATE in outer context
25  !ERROR: LASTPRIVATE variable 'b' is PRIVATE in outer context
26  !$omp do lastprivate(a,b)
27  do i = 1, 10
28    c(i) = a(i) + b(i) + i
29  end do
30  !$omp end do
31  !$omp end parallel
32
33  print *, c
34
35end program omp_lastprivate
36