1// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
2
3void foo() {
4}
5
6bool foobool(int argc) {
7  return argc;
8}
9
10struct S1; // expected-note 2 {{declared here}}
11extern S1 a;
12class S2 {
13  mutable int a;
14public:
15  S2():a(0) { }
16  S2(S2 &s2):a(s2.a) { }
17  static float S2s; // expected-note 4 {{mappable type cannot contain static members}}
18  static const float S2sc; // expected-note 4 {{mappable type cannot contain static members}}
19};
20const float S2::S2sc = 0;
21const S2 b;
22const S2 ba[5];
23class S3 {
24  int a;
25public:
26  S3():a(0) { }
27  S3(S3 &s3):a(s3.a) { }
28};
29const S3 c;
30const S3 ca[5];
31extern const int f;
32class S4 {
33  int a;
34  S4();
35  S4(const S4 &s4);
36public:
37  S4(int v):a(v) { }
38};
39class S5 {
40  int a;
41  S5():a(0) {}
42  S5(const S5 &s5):a(s5.a) { }
43public:
44  S5(int v):a(v) { }
45};
46struct S6 {
47  int ii;
48  int aa[30];
49  float xx;
50  double *pp;
51};
52struct S7 {
53  int i;
54  int a[50];
55  float x;
56  S6 s6[5];
57  double *p;
58  unsigned bfa : 4;
59};
60
61S3 h;
62#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
63
64typedef int to;
65
66template <typename T, int I> // expected-note {{declared here}}
67T tmain(T argc) {
68  const T d = 5;
69  const T da[5] = { 0 };
70  S4 e(4);
71  S5 g(5);
72  T i, t[20];
73  T &j = i;
74  T *k = &j;
75  T x;
76  T y;
77  T from;
78  const T (&l)[5] = da;
79  T *m;
80  S7 s7;
81
82#pragma omp target update from // expected-error {{expected '(' after 'from'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
83#pragma omp target update from( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
84#pragma omp target update from() // expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
85#pragma omp target update() // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
86#pragma omp target update from(alloc) // expected-error {{use of undeclared identifier 'alloc'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
87#pragma omp target update from(x)
88#pragma omp target update from(t[:I])
89#pragma omp target update from(T) // expected-error {{'T' does not refer to a value}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
90#pragma omp target update from(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
91#pragma omp target update from(S2::S2s)
92#pragma omp target update from(S2::S2sc)
93#pragma omp target update from(from)
94#pragma omp target update from(y x) // expected-error {{expected ',' or ')' in 'from' clause}}
95#pragma omp target update from(argc > 0 ? x : y) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
96#pragma omp target update from(S1) // expected-error {{'S1' does not refer to a value}}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
97#pragma omp target update from(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}}
98#pragma omp target update from(ba) // expected-error 2 {{type 'S2' is not mappable to target}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
99#pragma omp target update from(h) // expected-error {{threadprivate variables are not allowed in 'from' clause}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
100#pragma omp target update from(k), to(k) // expected-error 2 {{variable can appear only once in OpenMP 'target update' construct}} expected-note 2 {{used here}}
101#pragma omp target update from(t), from(t[:5]) // expected-error 2 {{variable can appear only once in OpenMP 'target update' construct}} expected-note 2 {{used here}}
102#pragma omp target update from(da)
103#pragma omp target update from(da[:4])
104
105#pragma omp target update from(x, a[:2]) // expected-error {{subscripted value is not an array or pointer}}
106#pragma omp target update from(x, c[:]) // expected-error {{subscripted value is not an array or pointer}}
107#pragma omp target update from(x, (m+1)[2]) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
108#pragma omp target update from(s7.i, s7.a[:3])
109#pragma omp target update from(s7.s6[1].aa[0:5])
110#pragma omp target update from(x, s7.s6[:5].aa[6]) // expected-error {{OpenMP array section is not allowed here}}
111#pragma omp target update from(x, s7.s6[:5].aa[:6]) // expected-error {{OpenMP array section is not allowed here}}
112#pragma omp target update from(s7.p[:10])
113#pragma omp target update from(x, s7.bfa) // expected-error {{bit fields cannot be used to specify storage in a 'from' clause}}
114#pragma omp target update from(x, s7.p[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
115#pragma omp target data map(to: s7.i)
116  {
117#pragma omp target update from(s7.x)
118  }
119
120  return 0;
121}
122
123int main(int argc, char **argv) {
124  const int d = 5;
125  const int da[5] = { 0 };
126  S4 e(4);
127  S5 g(5);
128  int i, t[20];
129  int &j = i;
130  int *k = &j;
131  int x;
132  int y;
133  int from;
134  const int (&l)[5] = da;
135  int *m;
136  S7 s7;
137
138#pragma omp target update from // expected-error {{expected '(' after 'from'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
139#pragma omp target update from( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
140#pragma omp target update from() // expected-error {{expected expression}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
141#pragma omp target update() // expected-warning {{extra tokens at the end of '#pragma omp target update' are ignored}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
142#pragma omp target update from(alloc) // expected-error {{use of undeclared identifier 'alloc'}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
143#pragma omp target update from(x)
144#pragma omp target update from(t[:i])
145#pragma omp target update from(S2::S2s)
146#pragma omp target update from(S2::S2sc)
147#pragma omp target update from(from)
148#pragma omp target update from(y x) // expected-error {{expected ',' or ')' in 'from' clause}}
149#pragma omp target update from(argc > 0 ? x : y) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
150#pragma omp target update from(S1) // expected-error {{'S1' does not refer to a value}}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
151#pragma omp target update from(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}}
152#pragma omp target update from(ba) // expected-error 2 {{type 'S2' is not mappable to target}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
153#pragma omp target update from(h) // expected-error {{threadprivate variables are not allowed in 'from' clause}} expected-error {{expected at least one 'to' clause or 'from' clause specified to '#pragma omp target update'}}
154#pragma omp target update from(k), to(k) // expected-error {{variable can appear only once in OpenMP 'target update' construct}} expected-note {{used here}}
155#pragma omp target update from(t), from(t[:5]) // expected-error {{variable can appear only once in OpenMP 'target update' construct}} expected-note {{used here}}
156#pragma omp target update from(da)
157#pragma omp target update from(da[:4])
158
159#pragma omp target update from(x, a[:2]) // expected-error {{subscripted value is not an array or pointer}}
160#pragma omp target update from(x, c[:]) // expected-error {{subscripted value is not an array or pointer}}
161#pragma omp target update from(x, (m+1)[2]) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}}
162#pragma omp target update from(s7.i, s7.a[:3])
163#pragma omp target update from(s7.s6[1].aa[0:5])
164#pragma omp target update from(x, s7.s6[:5].aa[6]) // expected-error {{OpenMP array section is not allowed here}}
165#pragma omp target update from(x, s7.s6[:5].aa[:6]) // expected-error {{OpenMP array section is not allowed here}}
166#pragma omp target update from(s7.p[:10])
167#pragma omp target update from(x, s7.bfa) // expected-error {{bit fields cannot be used to specify storage in a 'from' clause}}
168#pragma omp target update from(x, s7.p[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
169#pragma omp target data map(to: s7.i)
170  {
171#pragma omp target update from(s7.x)
172  }
173
174  return tmain<int, 3>(argc)+tmain<to, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}}
175}
176
177