[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / omp-firstprivate01.f90
blobd03cfc253c22f44ac7ffe8abdc6c67d9a40e1d0f
1 ! RUN: %S/test_errors.sh %s %t %flang_fc1 -fopenmp
2 ! REQUIRES: shell
3 ! OpenMP Version 4.5
4 ! 2.15.3.4 firstprivate Clause
5 ! Variables that appear in a firstprivate clause on a distribute or
6 ! worksharing constructs must not appear in the private or
7 ! reduction clause in a teams or parallel constructs in the outer context
9 program omp_firstprivate
10 integer :: i, a(10), b(10), c(10)
12 a = 10
13 b = 20
15 !$omp target
16 !$omp teams private(a, b)
17 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
18 !$omp distribute firstprivate(a)
19 do i = 1, 10
20 a(i) = a(i) + b(i) - i
21 end do
22 !$omp end distribute
23 !$omp end teams
24 !$omp teams reduction(+:a)
25 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
26 !$omp distribute firstprivate(a)
27 do i = 1, 10
28 b(i) = b(i) + a(i) + i
29 end do
30 !$omp end distribute
31 !$omp end teams
32 !$omp end target
34 print *, a, b
36 !$omp parallel private(a,b)
37 !ERROR: FIRSTPRIVATE variable 'b' is PRIVATE in outer context
38 !$omp do firstprivate(b)
39 do i = 1, 10
40 c(i) = a(i) + b(i) + i
41 end do
42 !$omp end do
43 !$omp end parallel
45 !$omp parallel reduction(-:a)
46 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
47 !$omp do firstprivate(a,b)
48 do i = 1, 10
49 c(i) = c(i) - a(i) * b(i) * i
50 end do
51 !$omp end do
52 !$omp end parallel
54 !$omp parallel reduction(+:a)
55 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
56 !$omp sections firstprivate(a, b)
57 !$omp section
58 c = c * a + b
59 !$omp end sections
60 !$omp end parallel
62 !$omp parallel reduction(-:a)
63 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
64 !$omp task firstprivate(a,b)
65 c = c - a * b
66 !$omp end task
67 !$omp end parallel
69 !$omp parallel reduction(+:b)
70 !ERROR: FIRSTPRIVATE variable 'b' is PRIVATE in outer context
71 !$omp taskloop firstprivate(b)
72 do i = 1, 10
73 c(i) = a(i) + b(i) + i
74 a = a+i
75 b = b-i
76 end do
77 !$omp end taskloop
78 !$omp end parallel
80 !$omp parallel firstprivate(a)
81 !ERROR: FIRSTPRIVATE variable 'a' is PRIVATE in outer context
82 !$omp single firstprivate(a)
83 print *, a
84 !$omp end single
85 !$omp end parallel
87 print *, c
89 end program omp_firstprivate