1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s
2 
3 int foo();
4 
5 template <class T>
foo()6 T foo() {
7   #pragma omp for ordered
8   for (int i = 0; i < 10; ++i) {
9     L1:
10       foo();
11     #pragma omp ordered
12     {
13       foo();
14       goto L1; // expected-error {{use of undeclared label 'L1'}}
15     }
16   }
17   #pragma omp for ordered
18   for (int i = 0; i < 10; ++i) {
19     foo();
20     goto L2; // expected-error {{use of undeclared label 'L2'}}
21     #pragma omp ordered
22     {
23       L2:
24       foo();
25     }
26   }
27   #pragma omp for ordered
28   for (int i = 0; i < 10; ++i) {
29     #pragma omp ordered threads threads // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'threads' clause}}
30     {
31       foo();
32     }
33   }
34   #pragma omp for ordered(1) // expected-note {{'ordered' clause with specified parameter}}
35   for (int i = 0; i < 10; ++i) {
36     #pragma omp ordered // expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
37     {
38       foo();
39     }
40   }
41   #pragma omp for ordered(1) // expected-note {{'ordered' clause with specified parameter}}
42   for (int i = 0; i < 10; ++i) {
43     #pragma omp ordered threads // expected-error {{'ordered' directive with 'threads' clause cannot be closely nested inside ordered region with specified parameter}}
44     {
45       foo();
46     }
47   }
48   #pragma omp ordered simd simd // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'simd' clause}}
49   {
50     foo();
51   }
52   #pragma omp simd
53   for (int i = 0; i < 10; ++i) {
54     #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
55     {
56       foo();
57     }
58   }
59   #pragma omp simd
60   for (int i = 0; i < 10; ++i) {
61     #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
62     {
63       foo();
64     }
65   }
66   #pragma omp for simd
67   for (int i = 0; i < 10; ++i) {
68     #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
69     {
70       foo();
71     }
72   }
73   #pragma omp for simd
74   for (int i = 0; i < 10; ++i) {
75     #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
76     {
77       foo();
78     }
79   }
80   #pragma omp parallel for simd
81   for (int i = 0; i < 10; ++i) {
82     #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
83     {
84       foo();
85     }
86   }
87   #pragma omp parallel for simd
88   for (int i = 0; i < 10; ++i) {
89     #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
90     {
91       foo();
92     }
93     #pragma omp ordered depend(source) // expected-error {{OpenMP constructs may not be nested inside a simd region}}
94   }
95 #pragma omp parallel for ordered
96   for (int i = 0; i < 10; ++i) {
97     #pragma omp ordered depend(source) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
98   }
99 #pragma omp parallel for ordered(1) // expected-note 3 {{'ordered' clause with specified parameter}}
100   for (int i = 0; i < 10; ++i) {
101     for (int j = 0; j < 10; ++j) {
102 #pragma omp ordered depend // expected-error {{expected '(' after 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
103 #pragma omp ordered depend( // expected-error {{expected ')'}} expected-error {{expected 'source' in OpenMP clause 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}} expected-warning {{missing ':' or ')' after dependency type - ignoring}} expected-note {{to match this '('}}
104 #pragma omp ordered depend(source // expected-error {{expected ')'}} expected-note {{to match this '('}}
105 #pragma omp ordered depend(source)
106                            if (i == j)
107 #pragma omp ordered depend(source) // expected-error {{'#pragma omp ordered' with 'depend' clause cannot be an immediate substatement}}
108                              ;
109 #pragma omp ordered depend(source) threads // expected-error {{'depend' clauses cannot be mixed with 'threads' clause}}
110 #pragma omp ordered simd depend(source) // expected-error {{'depend' clauses cannot be mixed with 'simd' clause}}
111 #pragma omp ordered depend(source) depend(source) // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'depend' clause with 'source' dependence}}
112 #pragma omp ordered depend(in : i) // expected-error {{expected 'source' in OpenMP clause 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
113     }
114   }
115 
116   return T();
117 }
118 
foo()119 int foo() {
120   #pragma omp for ordered
121   for (int i = 0; i < 10; ++i) {
122     L1:
123       foo();
124     #pragma omp ordered
125     {
126       foo();
127       goto L1; // expected-error {{use of undeclared label 'L1'}}
128     }
129   }
130   #pragma omp for ordered
131   for (int i = 0; i < 10; ++i) {
132     foo();
133     goto L2; // expected-error {{use of undeclared label 'L2'}}
134     #pragma omp ordered
135     {
136       L2:
137       foo();
138     }
139   }
140   #pragma omp for ordered
141   for (int i = 0; i < 10; ++i) {
142     #pragma omp ordered threads threads // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'threads' clause}}
143     {
144       foo();
145     }
146   }
147   #pragma omp for ordered(1) // expected-note {{'ordered' clause with specified parameter}}
148   for (int i = 0; i < 10; ++i) {
149     #pragma omp ordered // expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
150     {
151       foo();
152     }
153   }
154   #pragma omp for ordered(1) // expected-note {{'ordered' clause with specified parameter}}
155   for (int i = 0; i < 10; ++i) {
156     #pragma omp ordered threads // expected-error {{'ordered' directive with 'threads' clause cannot be closely nested inside ordered region with specified parameter}}
157     {
158       foo();
159     }
160   }
161   #pragma omp ordered simd simd // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'simd' clause}}
162   {
163     foo();
164   }
165   #pragma omp simd
166   for (int i = 0; i < 10; ++i) {
167     #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
168     {
169       foo();
170     }
171   }
172   #pragma omp simd
173   for (int i = 0; i < 10; ++i) {
174     #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
175     {
176       foo();
177     }
178   }
179   #pragma omp for simd
180   for (int i = 0; i < 10; ++i) {
181     #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
182     {
183       foo();
184     }
185   }
186   #pragma omp for simd
187   for (int i = 0; i < 10; ++i) {
188     #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
189     {
190       foo();
191     }
192   }
193   #pragma omp parallel for simd
194   for (int i = 0; i < 10; ++i) {
195     #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
196     {
197       foo();
198     }
199   }
200   #pragma omp parallel for simd
201   for (int i = 0; i < 10; ++i) {
202     #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
203     {
204       foo();
205     }
206     #pragma omp ordered depend(source) // expected-error {{OpenMP constructs may not be nested inside a simd region}}
207   }
208 #pragma omp parallel for ordered
209   for (int i = 0; i < 10; ++i) {
210     #pragma omp ordered depend(source) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
211   }
212 #pragma omp parallel for ordered(1) // expected-note 3 {{'ordered' clause with specified parameter}}
213   for (int i = 0; i < 10; ++i) {
214     for (int j = 0; j < 10; ++j) {
215 #pragma omp ordered depend // expected-error {{expected '(' after 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
216 #pragma omp ordered depend( // expected-error {{expected ')'}} expected-error {{expected 'source' in OpenMP clause 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}} expected-warning {{missing ':' or ')' after dependency type - ignoring}} expected-note {{to match this '('}}
217 #pragma omp ordered depend(source // expected-error {{expected ')'}} expected-note {{to match this '('}}
218 #pragma omp ordered depend(source)
219                            if (i == j)
220 #pragma omp ordered depend(source) // expected-error {{'#pragma omp ordered' with 'depend' clause cannot be an immediate substatement}}
221                              ;
222 #pragma omp ordered depend(source) threads // expected-error {{'depend' clauses cannot be mixed with 'threads' clause}}
223 #pragma omp ordered simd depend(source) // expected-error {{'depend' clauses cannot be mixed with 'simd' clause}}
224 #pragma omp ordered depend(source) depend(source) // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'depend' clause with 'source' dependence}}
225 #pragma omp ordered depend(in : i) // expected-error {{expected 'source' in OpenMP clause 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
226     }
227   }
228 
229   return foo<int>();
230 }
231