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