[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / omp-workshare02.f90
blob996c384303fb70ab68a66840766ba2f46908aecd
1 ! RUN: %S/test_errors.sh %s %t %flang -fopenmp
2 ! REQUIRES: shell
3 ! OpenMP Version 4.5
4 ! 2.7.4 workshare Construct
5 ! The !omp workshare construct must not contain any user defined
6 ! function calls unless the function is ELEMENTAL.
8 module my_mod
9 contains
10 integer function my_func()
11 my_func = 10
12 end function my_func
13 end module my_mod
15 subroutine workshare(aa, bb, cc, dd, ee, ff, n)
16 use my_mod
17 integer n, i, j
18 real aa(n), bb(n), cc(n), dd(n), ee(n), ff(n)
20 !$omp workshare
21 !ERROR: User defined non-ELEMENTAL function 'my_func' is not allowed in a WORKSHARE construct
22 aa = my_func()
23 cc = dd
24 ee = ff
26 !ERROR: User defined non-ELEMENTAL function 'my_func' is not allowed in a WORKSHARE construct
27 where (aa .ne. my_func()) aa = bb * cc
28 !ERROR: User defined non-ELEMENTAL function 'my_func' is not allowed in a WORKSHARE construct
29 where (dd .lt. 5) dd = aa * my_func()
31 !ERROR: User defined non-ELEMENTAL function 'my_func' is not allowed in a WORKSHARE construct
32 where (aa .ge. my_func())
33 !ERROR: User defined non-ELEMENTAL function 'my_func' is not allowed in a WORKSHARE construct
34 cc = aa + my_func()
35 !ERROR: User defined non-ELEMENTAL function 'my_func' is not allowed in a WORKSHARE construct
36 elsewhere (aa .le. my_func())
37 !ERROR: User defined non-ELEMENTAL function 'my_func' is not allowed in a WORKSHARE construct
38 cc = dd + my_func()
39 elsewhere
40 !ERROR: User defined non-ELEMENTAL function 'my_func' is not allowed in a WORKSHARE construct
41 cc = ee + my_func()
42 end where
44 !ERROR: User defined non-ELEMENTAL function 'my_func' is not allowed in a WORKSHARE construct
45 forall (j = 1:my_func()) aa(j) = aa(j) + bb(j)
47 forall (j = 1:10)
48 aa(j) = aa(j) + bb(j)
50 !ERROR: User defined non-ELEMENTAL function 'my_func' is not allowed in a WORKSHARE construct
51 where (cc .le. j) cc = cc + my_func()
52 end forall
54 !$omp atomic update
55 !ERROR: User defined non-ELEMENTAL function 'my_func' is not allowed in a WORKSHARE construct
56 j = j + my_func()
58 !$omp atomic capture
59 i = j
60 !ERROR: User defined non-ELEMENTAL function 'my_func' is not allowed in a WORKSHARE construct
61 j = j - my_func()
62 !$omp end atomic
64 !$omp end workshare
66 end subroutine workshare