[flang] Accept polymorphic component element in storage_size
[llvm-project.git] / flang / test / Semantics / OpenMP / omp-firstprivate01.f90
blob18e4cdd8a7d02579dfbc3453763edf0ecad41b40
1 ! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
2 ! OpenMP Version 4.5
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)
11 a = 10
12 b = 20
14 !ERROR: TARGET construct with nested TEAMS region contains statements or directives outside of the TEAMS construct
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