1ef8225444452a1486bd721f3285301fe84643b00Stephen Hines// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
2ef8225444452a1486bd721f3285301fe84643b00Stephen Hines
3ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesvoid foo() {
4ef8225444452a1486bd721f3285301fe84643b00Stephen Hines}
5ef8225444452a1486bd721f3285301fe84643b00Stephen Hines
6ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesbool foobool(int argc) {
7ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  return argc;
8ef8225444452a1486bd721f3285301fe84643b00Stephen Hines}
9ef8225444452a1486bd721f3285301fe84643b00Stephen Hines
10ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesstruct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
11ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesextern S1 a;
12ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesclass S2 {
13ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  mutable int a;
14ef8225444452a1486bd721f3285301fe84643b00Stephen Hines
15ef8225444452a1486bd721f3285301fe84643b00Stephen Hinespublic:
16ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S2() : a(0) {}
17ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S2(S2 &s2) : a(s2.a) {}
18ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  static float S2s; // expected-note {{static data member is predetermined as shared}}
19ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  static const float S2sc;
20ef8225444452a1486bd721f3285301fe84643b00Stephen Hines};
21ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesconst float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}}
22ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesconst S2 b;
23ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesconst S2 ba[5];
24ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesclass S3 { // expected-note 2 {{'S3' declared here}}
25ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  int a;
26ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S3 &operator=(const S3 &s3);
27ef8225444452a1486bd721f3285301fe84643b00Stephen Hines
28ef8225444452a1486bd721f3285301fe84643b00Stephen Hinespublic:
29ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S3() : a(0) {}
30ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S3(S3 &s3) : a(s3.a) {}
31ef8225444452a1486bd721f3285301fe84643b00Stephen Hines};
32ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesconst S3 c;         // expected-note {{global variable is predetermined as shared}}
33ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesconst S3 ca[5];     // expected-note {{global variable is predetermined as shared}}
34ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesextern const int f; // expected-note {{global variable is predetermined as shared}}
35ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesclass S4 {          // expected-note 3 {{'S4' declared here}}
36ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  int a;
37ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S4();
38ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S4(const S4 &s4);
39ef8225444452a1486bd721f3285301fe84643b00Stephen Hines
40ef8225444452a1486bd721f3285301fe84643b00Stephen Hinespublic:
41ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S4(int v) : a(v) {}
42ef8225444452a1486bd721f3285301fe84643b00Stephen Hines};
43ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesclass S5 { // expected-note {{'S5' declared here}}
44ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  int a;
45ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S5() : a(0) {}
46ef8225444452a1486bd721f3285301fe84643b00Stephen Hines
47ef8225444452a1486bd721f3285301fe84643b00Stephen Hinespublic:
48ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S5(const S5 &s5) : a(s5.a) {}
49ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S5(int v) : a(v) {}
50ef8225444452a1486bd721f3285301fe84643b00Stephen Hines};
51ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesclass S6 {
52ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  int a;
53ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S6() : a(0) {}
54ef8225444452a1486bd721f3285301fe84643b00Stephen Hines
55ef8225444452a1486bd721f3285301fe84643b00Stephen Hinespublic:
56ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S6(const S6 &s6) : a(s6.a) {}
57ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S6(int v) : a(v) {}
58ef8225444452a1486bd721f3285301fe84643b00Stephen Hines};
59ef8225444452a1486bd721f3285301fe84643b00Stephen Hines
60ef8225444452a1486bd721f3285301fe84643b00Stephen HinesS3 h;
61ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
62ef8225444452a1486bd721f3285301fe84643b00Stephen Hines
63ef8225444452a1486bd721f3285301fe84643b00Stephen Hinestemplate <class I, class C>
64ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesint foomain(int argc, char **argv) {
65ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  I e(4); // expected-note {{'e' defined here}}
66ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  I g(5); // expected-note {{'g' defined here}}
67ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  int i;
68ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  int &j = i; // expected-note {{'j' defined here}}
69ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
70ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
71ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
72ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
73ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
74ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
75ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
76ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
77ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
78ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate() // expected-error {{expected expression}}
79ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
80ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
81ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
82ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
83ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
84ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
85ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
86ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
87ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
88ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
89ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
90ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
91ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
92ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
93ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
94ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(argc)
95ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
96ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
97ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
98ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
99ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
100ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
101ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
102ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
103ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
104ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
105ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
106ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(argv[1]) // expected-error {{expected variable name}}
107ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
108ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
109ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
110ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}}
111ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
112ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
113ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
114ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
115ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
116ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
117ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
118ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp for'}}
119ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
120ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
121ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
122ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  {
123ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    int v = 0;
124ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    int i;                     // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
125ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(i) // expected-error {{lastprivate variable must be shared}}
126ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    for (int k = 0; k < argc; ++k) {
127ef8225444452a1486bd721f3285301fe84643b00Stephen Hines      i = k;
128ef8225444452a1486bd721f3285301fe84643b00Stephen Hines      v += i;
129ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    }
130ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  }
131ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel shared(i)
132ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel private(i)
133ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
134ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
135ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
136ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
137ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(i)
138ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (int k = 0; k < argc; ++k)
139ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    ++k;
140ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  return 0;
141ef8225444452a1486bd721f3285301fe84643b00Stephen Hines}
142ef8225444452a1486bd721f3285301fe84643b00Stephen Hines
143ef8225444452a1486bd721f3285301fe84643b00Stephen Hinesint main(int argc, char **argv) {
144ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  const int d = 5;       // expected-note {{constant variable is predetermined as shared}}
145ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}}
146ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S4 e(4);               // expected-note {{'e' defined here}}
147ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S5 g(5);               // expected-note {{'g' defined here}}
148ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S3 m;                  // expected-note 2 {{'m' defined here}}
149ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  S6 n(2);
150ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  int i;
151ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  int &j = i; // expected-note {{'j' defined here}}
152ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
153ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
154ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
155ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
156ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
157ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
158ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
159ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
160ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
161ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate() // expected-error {{expected expression}}
162ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
163ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
164ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
165ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
166ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
167ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
168ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
169ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
170ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
171ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
172ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
173ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
174ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
175ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
176ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
177ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(argc)
178ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
179ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
180ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
181ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
182ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
183ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
184ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
185ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}}
186ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
187ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
188ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
189ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(argv[1]) // expected-error {{expected variable name}}
190ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
191ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
192ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
193ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(2 * 2) // expected-error {{expected variable name}}
194ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
195ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
196ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
197ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(ba)
198ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
199ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
200ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
201ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
202ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
203ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
204ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
205ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
206ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
207ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
208ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  int xa;
209ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
210ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(xa) // OK
211ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
212ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
213ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
214ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
215ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
216ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
217ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
218ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
219ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
220ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
221ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
222ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp for'}}
223ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
224ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
225ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
226ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(e, g) // expected-error 2 {{lastprivate variable must have an accessible, unambiguous default constructor}}
227ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
228ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
229ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
230ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}}
231ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
232ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
233ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
234ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
235ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
236ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
237ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
238ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
239ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
240ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
241ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
242ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(i)
243ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
244ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
245ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel private(xa) // expected-note {{defined as private}}
246ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(xa)  // expected-error {{lastprivate variable must be shared}}
247ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
248ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
249ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel reduction(+ : xa) // expected-note {{defined as reduction}}
250ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(xa)        // expected-error {{lastprivate variable must be shared}}
251ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
252ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
253ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
254ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(j) // expected-error {{arguments of OpenMP clause 'lastprivate' cannot be of reference type}}
255ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
256ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
257ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
258ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for firstprivate(m) lastprivate(m) // expected-error {{lastprivate variable must have an accessible, unambiguous copy assignment operator}}
259ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
260ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
261ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp parallel
262ef8225444452a1486bd721f3285301fe84643b00Stephen Hines#pragma omp for lastprivate(n) firstprivate(n) // OK
263ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  for (i = 0; i < argc; ++i)
264ef8225444452a1486bd721f3285301fe84643b00Stephen Hines    foo();
265ef8225444452a1486bd721f3285301fe84643b00Stephen Hines  return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
266ef8225444452a1486bd721f3285301fe84643b00Stephen Hines}
267