1! RUN: %python %S/../test_errors.py %s %flang -fopenmp
2
3! OpenMP Version 5.0
4! Check OpenMP construct validity for the following directives:
5! 2.7 Teams Construct
6
7program main
8  integer :: i, j, N = 10
9  real :: a, b, c
10
11  !$omp teams
12  a = 3.14
13  !$omp end teams
14
15  !$omp target
16  !$omp teams
17  a = 3.14
18  !$omp end teams
19  !$omp end target
20
21  !$omp target
22  !$omp parallel
23  !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
24  !$omp teams
25  a = 3.14
26  !$omp end teams
27  !$omp end parallel
28  !$omp end target
29
30  !$omp parallel
31  !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
32  !$omp teams
33  a = 3.14
34  !$omp end teams
35  !$omp end parallel
36
37  !$omp do
38  do i = 1, N
39  !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
40  !$omp teams
41  a = 3.14
42  !$omp end teams
43  end do
44
45  !$omp master
46  !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
47  !$omp teams
48  a = 3.14
49  !$omp end teams
50  !$omp end master
51
52  !$omp target parallel
53  !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
54  !$omp teams
55  a = 3.14
56  !$omp end teams
57  !$omp end target parallel
58
59  !$omp target
60  !$omp teams
61  !ERROR: Only `DISTRIBUTE` or `PARALLEL` regions are allowed to be strictly nested inside `TEAMS` region.
62  !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
63  !$omp teams
64  a = 3.14
65  !$omp end teams
66  !$omp end teams
67  !$omp end target
68
69  !$omp target teams
70  !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
71  !$omp teams
72  a = 3.14
73  !$omp end teams
74  !$omp end target teams
75
76  !ERROR: TARGET construct with nested TEAMS region contains statements or directives outside of the TEAMS construct
77  !$omp target
78  do i = 1, N
79    !$omp teams
80    a = 3.14
81    !$omp end teams
82  enddo
83  !$omp end target
84
85  !ERROR: TARGET construct with nested TEAMS region contains statements or directives outside of the TEAMS construct
86  !$omp target
87  if (i .GT. 1) then
88    if (j .GT. 1) then
89      !$omp teams
90      a = 3.14
91      !$omp end teams
92    end if
93  end if
94  !$omp end target
95
96  !ERROR: TARGET construct with nested TEAMS region contains statements or directives outside of the TEAMS construct
97  !$omp target
98  b = 3.14
99  !$omp teams
100  a = 3.14
101  !$omp end teams
102  !$omp end target
103
104  !ERROR: TARGET construct with nested TEAMS region contains statements or directives outside of the TEAMS construct
105  !$omp target
106  !$omp teams
107  a = 3.14
108  !$omp end teams
109  c = 3.14
110  !$omp end target
111
112end program main
113