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