• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -verify=expected,omp45 -std=c++11 %s -Wuninitialized
2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -verify=expected,omp50 -std=c++11 %s -Wuninitialized
3 
4 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -verify=expected,omp45 -std=c++11 %s -Wuninitialized
5 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -verify=expected,omp50 -std=c++11 %s -Wuninitialized
6 
xxx(int argc)7 void xxx(int argc) {
8   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
9 #pragma omp target
10 #pragma omp teams distribute simd
11   for (int i = 0; i < 10; ++i)
12     argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
13 }
14 
foo()15 void foo() {
16 }
17 
18 static int pvt;
19 #pragma omp threadprivate(pvt)
20 
21 #pragma omp teams distribute simd // expected-error {{unexpected OpenMP directive '#pragma omp teams distribute simd'}}
22 
main(int argc,char ** argv)23 int main(int argc, char **argv) {
24   #pragma omp target
25   #pragma omp teams distribute simd
26   f; // expected-error {{use of undeclared identifier 'f'}}
27 #pragma omp target
28 #pragma omp teams distribute simd { // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
29   for (int i = 0; i < argc; ++i)
30     foo();
31 #pragma omp target
32 #pragma omp teams distribute simd ( // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
33   for (int i = 0; i < argc; ++i)
34     foo();
35 #pragma omp target
36 #pragma omp teams distribute simd[ // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
37   for (int i = 0; i < argc; ++i)
38     foo();
39 #pragma omp target
40 #pragma omp teams distribute simd] // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
41   for (int i = 0; i < argc; ++i)
42     foo();
43 #pragma omp target
44 #pragma omp teams distribute simd) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
45   for (int i = 0; i < argc; ++i)
46     foo();
47 #pragma omp target
48 #pragma omp teams distribute simd } // expected-warning {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
49   for (int i = 0; i < argc; ++i)
50     foo();
51 #pragma omp target
52 #pragma omp teams distribute simd
53   for (int i = 0; i < argc; ++i)
54     foo();
55 // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams distribute simd' are ignored}}
56 #pragma omp target
57 #pragma omp teams distribute simd unknown()
58   for (int i = 0; i < argc; ++i)
59     foo();
60 L1:
61   for (int i = 0; i < argc; ++i)
62     foo();
63 #pragma omp target
64 #pragma omp teams distribute simd
65   for (int i = 0; i < argc; ++i)
66     foo();
67 #pragma omp target
68 #pragma omp teams distribute simd
69   for (int i = 0; i < argc; ++i) {
70     goto L1; // expected-error {{use of undeclared label 'L1'}}
71     argc++;
72   }
73 
74   for (int i = 0; i < 10; ++i) {
75     switch (argc) {
76     case (0):
77 #pragma omp target
78 #pragma omp teams distribute simd
79       for (int i = 0; i < argc; ++i) {
80         foo();
81         break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
82         continue;
83       }
84     default:
85       break;
86     }
87   }
88 #pragma omp target
89 #pragma omp teams distribute simd default(none) // expected-note {{explicit data sharing attribute requested here}}
90   for (int i = 0; i < 10; ++i)
91     ++argc; // expected-error {{ariable 'argc' must have explicitly specified data sharing attributes}}
92 
93   goto L2; // expected-error {{use of undeclared label 'L2'}}
94 #pragma omp target
95 #pragma omp teams distribute simd
96   for (int i = 0; i < argc; ++i)
97   L2:
98   foo();
99 #pragma omp target
100 #pragma omp teams distribute simd
101   for (int i = 0; i < argc; ++i) {
102     return 1; // expected-error {{cannot return from OpenMP region}}
103   }
104 
105   [[]] // expected-error {{an attribute list cannot appear here}}
106 #pragma omp target
107 #pragma omp teams distribute simd
108       for (int n = 0; n < 100; ++n) {
109   }
110 
111 #pragma omp target
112 #pragma omp teams distribute simd copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp teams distribute simd'}}
113   for (int n = 0; n < 100; ++n) {}
114 
115   return 0;
116 }
117 
test_ordered()118 void test_ordered() {
119 #pragma omp target
120 #pragma omp teams distribute simd ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp teams distribute simd'}}
121   for (int i = 0; i < 16; ++i)
122     ;
123 }
124 
test_nontemporal()125 void test_nontemporal() {
126   int i;
127 #pragma omp target
128 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
129 #pragma omp teams distribute simd nontemporal(
130   for (i = 0; i < 16; ++i)
131     ;
132 #pragma omp target
133 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 2 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
134 #pragma omp teams distribute simd nontemporal(,
135   for (i = 0; i < 16; ++i)
136     ;
137 #pragma omp target
138 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 2 {{expected expression}}
139 #pragma omp teams distribute simd nontemporal(, )
140   for (i = 0; i < 16; ++i)
141     ;
142 #pragma omp target
143 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{expected expression}}
144 #pragma omp teams distribute simd nontemporal()
145   for (i = 0; i < 16; ++i)
146     ;
147 #pragma omp target
148 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{expected '(' for function-style cast or type construction}}
149 #pragma omp teams distribute simd nontemporal(int)
150   for (i = 0; i < 16; ++i)
151     ;
152 #pragma omp target
153 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} omp50-error@+1 {{expected variable name}}
154 #pragma omp teams distribute simd nontemporal(0)
155   for (i = 0; i < 16; ++i)
156     ;
157 #pragma omp target
158 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{use of undeclared identifier 'x'}}
159 #pragma omp teams distribute simd nontemporal(x)
160   for (i = 0; i < 16; ++i)
161     ;
162 #pragma omp target
163 // expected-error@+2 {{use of undeclared identifier 'x'}}
164 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{use of undeclared identifier 'y'}}
165 #pragma omp teams distribute simd nontemporal(x, y)
166   for (i = 0; i < 16; ++i)
167     ;
168 #pragma omp target
169 // expected-error@+3 {{use of undeclared identifier 'x'}}
170 // expected-error@+2 {{use of undeclared identifier 'y'}}
171 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{use of undeclared identifier 'z'}}
172 #pragma omp teams distribute simd nontemporal(x, y, z)
173   for (i = 0; i < 16; ++i)
174     ;
175 
176   int x, y;
177 #pragma omp target
178 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
179 #pragma omp teams distribute simd nontemporal(x :)
180   for (i = 0; i < 16; ++i)
181     ;
182 #pragma omp target
183 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}}
184 #pragma omp teams distribute simd nontemporal(x :, )
185   for (i = 0; i < 16; ++i)
186     ;
187 
188 #pragma omp target
189 // omp50-note@+2 {{defined as nontemporal}}
190 // omp45-error@+1 2 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} omp50-error@+1 {{a variable cannot appear in more than one nontemporal clause}}
191 #pragma omp teams distribute simd nontemporal(x) nontemporal(x)
192   for (i = 0; i < 16; ++i)
193     ;
194 
195 #pragma omp target
196 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}}
197 #pragma omp teams distribute simd private(x) nontemporal(x)
198   for (i = 0; i < 16; ++i)
199     ;
200 
201 #pragma omp target
202 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}}
203 #pragma omp teams distribute simd nontemporal(x) private(x)
204   for (i = 0; i < 16; ++i)
205     ;
206 
207 #pragma omp target
208 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}}
209 #pragma omp teams distribute simd nontemporal(x, y : 0)
210   for (i = 0; i < 16; ++i)
211     ;
212 
213 #pragma omp target
214 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}}
215 #pragma omp teams distribute simd nontemporal(x) lastprivate(x)
216   for (i = 0; i < 16; ++i)
217     ;
218 
219 #pragma omp target
220 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute simd'}}
221 #pragma omp teams distribute simd lastprivate(x) nontemporal(x)
222   for (i = 0; i < 16; ++i)
223     ;
224 #pragma omp target
225 #pragma omp teams distribute simd order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} expected-error {{expected '(' after 'order'}}
226   for (int i = 0; i < 10; ++i)
227     ;
228 #pragma omp target
229 #pragma omp teams distribute simd order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
230   for (int i = 0; i < 10; ++i)
231     ;
232 #pragma omp target
233 #pragma omp teams distribute simd order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
234   for (int i = 0; i < 10; ++i)
235     ;
236 #pragma omp target
237 #pragma omp teams distribute simd order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
238   for (int i = 0; i < 10; ++i)
239     ;
240 #pragma omp target
241 #pragma omp teams distribute simd order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute simd'}}
242   for (int i = 0; i < 10; ++i)
243     ;
244 }
245 
246