• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -std=c++11 -verify -fopenmp -ferror-limit 200 %s
2 struct ST {
3   int *a;
4 };
5 typedef int arr[10];
6 typedef ST STarr[10];
7 struct SA {
8   const int d = 5;
9   const int da[5] = { 0 };
10   ST e;
11   ST g[10];
12   STarr &rg = g;
13   int i;
14   int &j = i;
15   int *k = &j;
16   int *&z = k;
17   int aa[10];
18   arr &raa = aa;
funcSA19   void func(int arg) {
20 #pragma omp target is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
21     {}
22 #pragma omp target is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
23     {}
24 #pragma omp target is_device_ptr() // expected-error {{expected expression}}
25     {}
26 #pragma omp target is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
27     {}
28 #pragma omp target is_device_ptr(arg // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
29     {}
30 #pragma omp target is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
31     {}
32 #pragma omp target is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
33     {}
34 #pragma omp target is_device_ptr(k) // OK
35     {}
36 #pragma omp target is_device_ptr(z) // OK
37     {}
38 #pragma omp target is_device_ptr(aa) // OK
39     {}
40 #pragma omp target is_device_ptr(raa) // OK
41     {}
42 #pragma omp target is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
43     {}
44 #pragma omp target is_device_ptr(g) // OK
45     {}
46 #pragma omp target is_device_ptr(rg) // OK
47     {}
48 #pragma omp target is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
49     {}
50 #pragma omp target is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
51     {}
52 #pragma omp target is_device_ptr(da) // OK
53     {}
54   return;
55  }
56 };
57 struct SB {
58   unsigned A;
59   unsigned B;
60   float Arr[100];
61   float *Ptr;
fooSB62   float *foo() {
63     return &Arr[0];
64   }
65 };
66 
67 struct SC {
68   unsigned A : 2;
69   unsigned B : 3;
70   unsigned C;
71   unsigned D;
72   float Arr[100];
73   SB S;
74   SB ArrS[100];
75   SB *PtrS;
76   SB *&RPtrS;
77   float *Ptr;
78 
SCSC79   SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
80 };
81 
82 union SD {
83   unsigned A;
84   float B;
85 };
86 
87 struct S1;
88 extern S1 a;
89 class S2 {
90   mutable int a;
91 public:
S2()92   S2():a(0) { }
S2(S2 & s2)93   S2(S2 &s2):a(s2.a) { }
94   static float S2s;
95   static const float S2sc;
96 };
97 const float S2::S2sc = 0;
98 const S2 b;
99 const S2 ba[5];
100 class S3 {
101   int a;
102 public:
S3()103   S3():a(0) { }
S3(S3 & s3)104   S3(S3 &s3):a(s3.a) { }
105 };
106 const S3 c;
107 const S3 ca[5];
108 extern const int f;
109 class S4 {
110   int a;
111   S4();
112   S4(const S4 &s4);
113 public:
S4(int v)114   S4(int v):a(v) { }
115 };
116 class S5 {
117   int a;
S5()118   S5():a(0) {}
S5(const S5 & s5)119   S5(const S5 &s5):a(s5.a) { }
120 public:
S5(int v)121   S5(int v):a(v) { }
122 };
123 
124 S3 h;
125 #pragma omp threadprivate(h)
126 
127 typedef struct {
128   int a;
129 } S6;
130 
131 template <typename T, int I>
tmain(T argc)132 T tmain(T argc) {
133   const T d = 5;
134   const T da[5] = { 0 };
135   S4 e(4);
136   S5 g(5);
137   S6 h[10];
138   auto &rh = h;
139   T i;
140   T &j = i;
141   T *k = &j;
142   T *&z = k;
143   T aa[10];
144   auto &raa = aa;
145 #pragma omp target is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
146   {}
147 #pragma omp target is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
148   {}
149 #pragma omp target is_device_ptr() // expected-error {{expected expression}}
150   {}
151 #pragma omp target is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
152   {}
153 #pragma omp target is_device_ptr(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
154   {}
155 #pragma omp target is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
156   {}
157 #pragma omp target is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
158   {}
159 #pragma omp target is_device_ptr(k) // OK
160   {}
161 #pragma omp target is_device_ptr(z) // OK
162   {}
163 #pragma omp target is_device_ptr(aa) // OK
164   {}
165 #pragma omp target is_device_ptr(raa) // OK
166   {}
167 #pragma omp target is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
168   {}
169 #pragma omp target is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
170   {}
171 #pragma omp target is_device_ptr(h) // OK
172   {}
173 #pragma omp target is_device_ptr(rh) // OK
174   {}
175 #pragma omp target is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
176   {}
177 #pragma omp target is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
178   {}
179 #pragma omp target is_device_ptr(da) // OK
180   {}
181   return 0;
182 }
183 
main(int argc,char ** argv)184 int main(int argc, char **argv) {
185   const int d = 5;
186   const int da[5] = { 0 };
187   S4 e(4);
188   S5 g(5);
189   S6 h[10];
190   auto &rh = h;
191   int i;
192   int &j = i;
193   int *k = &j;
194   int *&z = k;
195   int aa[10];
196   auto &raa = aa;
197 #pragma omp target is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
198   {}
199 #pragma omp target is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
200   {}
201 #pragma omp target is_device_ptr() // expected-error {{expected expression}}
202   {}
203 #pragma omp target is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
204   {}
205 #pragma omp target is_device_ptr(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
206   {}
207 #pragma omp target is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
208   {}
209 #pragma omp target is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
210   {}
211 #pragma omp target is_device_ptr(k) // OK
212   {}
213 #pragma omp target is_device_ptr(z) // OK
214   {}
215 #pragma omp target is_device_ptr(aa) // OK
216   {}
217 #pragma omp target is_device_ptr(raa) // OK
218   {}
219 #pragma omp target is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
220   {}
221 #pragma omp target is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
222   {}
223 #pragma omp target is_device_ptr(h) // OK
224   {}
225 #pragma omp target is_device_ptr(rh) // OK
226   {}
227 #pragma omp target is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
228   {}
229 #pragma omp target is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
230   {}
231 #pragma omp target is_device_ptr(da) // OK
232   {}
233   return tmain<int, 3>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}}
234 }
235