address-spaces-conversions-cl2.0.cl
22.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=CL2.0
// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=CL2.0
// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=CL2.0
// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=clc++
// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=clc++
// RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=clc++
/* OpenCLC v2.0 adds a set of restrictions for conversions between pointers to
* different address spaces, mainly described in Sections 6.5.5 and 6.5.6.
*
* It adds notion of overlapping address spaces. The main differention is that
* an unnamed address space is added, called '__generic'. Pointers to the
* generic address space can be interchangabley used with pointers to any
* other address space except for __constant address space (Section 6.5.5).
*
* Based on this there are 3 sets of tests: __generic, named (__global in this
* case), and __constant, that should cover all program paths for CL address
* space conversions used in initialisations, assignments, casts, comparisons
* and arithmetic operations.
*/
#ifdef GENERIC
#define AS __generic
#define AS_COMP __local
#define AS_INCOMP __constant
#endif
#ifdef GLOBAL
#define AS __global
#define AS_COMP __global
#define AS_INCOMP __local
#endif
#ifdef CONSTANT
#define AS __constant
#define AS_COMP __constant
#define AS_INCOMP __global
#endif
void f_glob(__global int *arg_glob) {}
#ifndef GLOBAL
#if !__OPENCL_CPP_VERSION__
// expected-note@-3{{passing argument to parameter 'arg_glob' here}}
#else
// expected-note-re@-5{{candidate function not viable: cannot pass pointer to address space '__{{generic|constant}}' as a pointer to address space '__global' in 1st argument}}
#endif
#endif
void f_loc(__local int *arg_loc) {}
#if !__OPENCL_CPP_VERSION__
// expected-note@-2{{passing argument to parameter 'arg_loc' here}}
#else
// expected-note-re@-4{{candidate function not viable: cannot pass pointer to address space '__{{global|generic|constant}}' as a pointer to address space '__local' in 1st argument}}
#endif
void f_const(__constant int *arg_const) {}
#ifndef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-note@-3{{passing argument to parameter 'arg_const' here}}
#else
// expected-note-re@-5{{candidate function not viable: cannot pass pointer to address space '__{{global|generic}}' as a pointer to address space '__constant' in 1st argument}}
#endif
#endif
void f_priv(__private int *arg_priv) {}
#if !__OPENCL_CPP_VERSION__
// expected-note@-2{{passing argument to parameter 'arg_priv' here}}
#else
// expected-note-re@-4{{candidate function not viable: cannot pass pointer to address space '__{{global|generic|constant}}' as a pointer to address space '__private' in 1st argument}}
#endif
void f_gen(__generic int *arg_gen) {}
#ifdef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-note@-3{{passing argument to parameter 'arg_gen' here}}
#else
// expected-note@-5{{candidate function not viable: cannot pass pointer to address space '__constant' as a pointer to address space '__generic' in 1st argument}}
#endif
#endif
void test_conversion(__global int *arg_glob, __local int *arg_loc,
__constant int *arg_const, __private int *arg_priv,
__generic int *arg_gen) {
AS int *var_init1 = arg_glob;
#ifdef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error@-3{{initializing '__constant int *__private' with an expression of type '__global int *__private' changes address space of pointer}}
#else
// expected-error@-5{{cannot initialize a variable of type '__constant int *__private' with an lvalue of type '__global int *__private'}}
#endif
#endif
AS int *var_init2 = arg_loc;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{initializing '__{{global|constant}} int *__private' with an expression of type '__local int *__private' changes address space of pointer}}
#else
// expected-error-re@-5{{cannot initialize a variable of type '__{{global|constant}} int *__private' with an lvalue of type '__local int *__private'}}
#endif
#endif
AS int *var_init3 = arg_const;
#ifndef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{initializing '__{{global|generic}} int *__private' with an expression of type '__constant int *__private' changes address space of pointer}}
#else
// expected-error-re@-5{{cannot initialize a variable of type '__{{global|generic}} int *__private' with an lvalue of type '__constant int *__private'}}
#endif
#endif
AS int *var_init4 = arg_priv;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{initializing '__{{global|constant}} int *__private' with an expression of type '__private int *__private' changes address space of pointer}}
#else
// expected-error-re@-5{{cannot initialize a variable of type '__{{global|constant}} int *__private' with an lvalue of type '__private int *__private'}}
#endif
#endif
AS int *var_init5 = arg_gen;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{initializing '__{{global|constant}} int *__private' with an expression of type '__generic int *__private' changes address space of pointer}}
#else
// expected-error-re@-5{{cannot initialize a variable of type '__{{global|constant}} int *__private' with an lvalue of type '__generic int *__private'}}
#endif
#endif
AS int *var_cast1 = (AS int *)arg_glob;
#ifdef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error@-3{{casting '__global int *' to type '__constant int *' changes address space of pointer}}
#else
// expected-error@-5{{C-style cast from '__global int *' to '__constant int *' converts between mismatching address spaces}}
#endif
#endif
AS int *var_cast2 = (AS int *)arg_loc;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{casting '__local int *' to type '__{{global|constant}} int *' changes address space of pointer}}
#else
// expected-error-re@-5{{C-style cast from '__local int *' to '__{{global|constant}} int *' converts between mismatching address spaces}}
#endif
#endif
AS int *var_cast3 = (AS int *)arg_const;
#ifndef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{casting '__constant int *' to type '__{{global|generic}} int *' changes address space of pointer}}
#else
// expected-error-re@-5{{C-style cast from '__constant int *' to '__{{global|generic}} int *' converts between mismatching address spaces}}
#endif
#endif
AS int *var_cast4 = (AS int *)arg_priv;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{casting '__private int *' to type '__{{global|constant}} int *' changes address space of pointer}}
#else
// expected-error-re@-5{{C-style cast from '__private int *' to '__{{global|constant}} int *' converts between mismatching address spaces}}
#endif
#endif
AS int *var_cast5 = (AS int *)arg_gen;
#ifdef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error@-3{{casting '__generic int *' to type '__constant int *' changes address space of pointer}}
#else
// expected-error@-5{{C-style cast from '__generic int *' to '__constant int *' converts between mismatching address spaces}}
#endif
#endif
AS int *var_impl;
var_impl = arg_glob;
#ifdef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error@-3{{assigning '__global int *__private' to '__constant int *__private' changes address space of pointer}}
#else
// expected-error@-5{{assigning to '__constant int *' from incompatible type '__global int *__private'}}
#endif
#endif
var_impl = arg_loc;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{assigning '__local int *__private' to '__{{global|constant}} int *__private' changes address space of pointer}}
#else
// expected-error-re@-5{{assigning to '__{{global|constant}} int *' from incompatible type '__local int *__private'}}
#endif
#endif
var_impl = arg_const;
#ifndef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{assigning '__constant int *__private' to '__{{global|generic}} int *__private' changes address space of pointer}}
#else
// expected-error-re@-5{{assigning to '__{{global|generic}} int *' from incompatible type '__constant int *__private'}}
#endif
#endif
var_impl = arg_priv;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{assigning '__private int *__private' to '__{{global|constant}} int *__private' changes address space of pointer}}
#else
// expected-error-re@-5{{assigning to '__{{global|constant}} int *' from incompatible type '__private int *__private'}}
#endif
#endif
var_impl = arg_gen;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{assigning '__generic int *__private' to '__{{global|constant}} int *__private' changes address space of pointer}}
#else
// expected-error-re@-5{{assigning to '__{{global|constant}} int *' from incompatible type '__generic int *__private'}}
#endif
#endif
var_cast1 = (AS int *)arg_glob;
#ifdef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error@-3{{casting '__global int *' to type '__constant int *' changes address space of pointer}}
#else
// expected-error@-5{{C-style cast from '__global int *' to '__constant int *' converts between mismatching address spaces}}
#endif
#endif
var_cast2 = (AS int *)arg_loc;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{casting '__local int *' to type '__{{global|constant}} int *' changes address space of pointer}}
#else
// expected-error-re@-5{{C-style cast from '__local int *' to '__{{global|constant}} int *' converts between mismatching address spaces}}
#endif
#endif
var_cast3 = (AS int *)arg_const;
#ifndef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{casting '__constant int *' to type '__{{global|generic}} int *' changes address space of pointer}}
#else
// expected-error-re@-5{{C-style cast from '__constant int *' to '__{{global|generic}} int *' converts between mismatching address spaces}}
#endif
#endif
var_cast4 = (AS int *)arg_priv;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{casting '__private int *' to type '__{{global|constant}} int *' changes address space of pointer}}
#else
// expected-error-re@-5{{C-style cast from '__private int *' to '__{{global|constant}} int *' converts between mismatching address spaces}}
#endif
#endif
var_cast5 = (AS int *)arg_gen;
#ifdef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error@-3{{casting '__generic int *' to type '__constant int *' changes address space of pointer}}
#else
// expected-error@-5{{C-style cast from '__generic int *' to '__constant int *' converts between mismatching address spaces}}
#endif
#endif
AS int *var_cmp;
int b = var_cmp != arg_glob;
#ifdef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error@-3{{comparison between ('__constant int *' and '__global int *') which are pointers to non-overlapping address spaces}}
#else
// expected-error@-5{{comparison of distinct pointer types ('__constant int *' and '__global int *')}}
#endif
#endif
b = var_cmp != arg_loc;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{comparison between ('__{{global|constant}} int *' and '__local int *') which are pointers to non-overlapping address spaces}}
#else
// expected-error-re@-5{{comparison of distinct pointer types ('__{{global|constant}} int *' and '__local int *')}}
#endif
#endif
b = var_cmp == arg_const;
#ifndef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{comparison between ('__{{global|generic}} int *' and '__constant int *') which are pointers to non-overlapping address spaces}}
#else
// expected-error-re@-5{{comparison of distinct pointer types ('__{{global|generic}} int *' and '__constant int *')}}
#endif
#endif
b = var_cmp <= arg_priv;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{comparison between ('__{{global|constant}} int *' and '__private int *') which are pointers to non-overlapping address spaces}}
#else
// expected-error-re@-5{{comparison of distinct pointer types ('__{{global|constant}} int *' and '__private int *')}}
#endif
#endif
b = var_cmp >= arg_gen;
#ifdef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error@-3{{comparison between ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}}
#else
// expected-error@-5{{comparison of distinct pointer types ('__constant int *' and '__generic int *')}}
#endif
#endif
AS int *var_sub;
b = var_sub - arg_glob;
#ifdef CONSTANT
// expected-error@-2{{arithmetic operation with operands of type ('__constant int *' and '__global int *') which are pointers to non-overlapping address spaces}}
#endif
b = var_sub - arg_loc;
#ifndef GENERIC
// expected-error-re@-2{{arithmetic operation with operands of type ('__{{global|constant}} int *' and '__local int *') which are pointers to non-overlapping address spaces}}
#endif
b = var_sub - arg_const;
#ifndef CONSTANT
// expected-error-re@-2{{arithmetic operation with operands of type ('__{{global|generic}} int *' and '__constant int *') which are pointers to non-overlapping address spaces}}
#endif
b = var_sub - arg_priv;
#ifndef GENERIC
// expected-error-re@-2{{arithmetic operation with operands of type ('__{{global|constant}} int *' and '__private int *') which are pointers to non-overlapping address spaces}}
#endif
b = var_sub - arg_gen;
#ifdef CONSTANT
// expected-error@-2{{arithmetic operation with operands of type ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}}
#endif
f_glob(var_sub);
#ifndef GLOBAL
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{passing '__{{constant|generic}} int *__private' to parameter of type '__global int *' changes address space of pointer}}
#else
// expected-error@-5{{no matching function for call to 'f_glob'}}
#endif
#endif
f_loc(var_sub);
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-2{{passing '__{{global|constant|generic}} int *__private' to parameter of type '__local int *' changes address space of pointer}}
#else
// expected-error@-4{{no matching function for call to 'f_loc'}}
#endif
f_const(var_sub);
#ifndef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{passing '__{{global|generic}} int *__private' to parameter of type '__constant int *' changes address space of pointer}}
#else
// expected-error@-5{{no matching function for call to 'f_const'}}
#endif
#endif
f_priv(var_sub);
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-2{{passing '__{{global|constant|generic}} int *__private' to parameter of type '__private int *' changes address space of pointer}}
#else
// expected-error@-4{{no matching function for call to 'f_priv'}}
#endif
f_gen(var_sub);
#ifdef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error@-3{{passing '__constant int *__private' to parameter of type '__generic int *' changes address space of pointer}}
#else
// expected-error@-5{{no matching function for call to 'f_gen'}}
#endif
#endif
}
void test_ternary() {
AS int *var_cond;
__generic int *var_gen;
__global int *var_glob;
var_gen = 0 ? var_cond : var_glob;
#ifdef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error@-3{{conditional operator with the second and third operands of type ('__constant int *' and '__global int *') which are pointers to non-overlapping address spaces}}
#else
// expected-error@-5{{incompatible operand types ('__constant int *' and '__global int *')}}
#endif
#endif
__local int *var_loc;
var_gen = 0 ? var_cond : var_loc;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{conditional operator with the second and third operands of type ('__{{global|constant}} int *' and '__local int *') which are pointers to non-overlapping address spaces}}
#else
// expected-error-re@-5{{incompatible operand types ('__{{global|constant}} int *' and '__local int *')}}
#endif
#endif
__constant int *var_const;
var_cond = 0 ? var_cond : var_const;
#ifndef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{conditional operator with the second and third operands of type ('__{{global|generic}} int *' and '__constant int *') which are pointers to non-overlapping address spaces}}
#else
// expected-error-re@-5{{incompatible operand types ('__{{global|generic}} int *' and '__constant int *')}}
#endif
#endif
__private int *var_priv;
var_gen = 0 ? var_cond : var_priv;
#ifndef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error-re@-3{{conditional operator with the second and third operands of type ('__{{global|constant}} int *' and '__private int *') which are pointers to non-overlapping address spaces}}
#else
// expected-error-re@-5{{incompatible operand types ('__{{global|constant}} int *' and '__private int *')}}
#endif
#endif
var_gen = 0 ? var_cond : var_gen;
#ifdef CONSTANT
#if !__OPENCL_CPP_VERSION__
// expected-error@-3{{conditional operator with the second and third operands of type ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}}
#else
// expected-error@-5{{incompatible operand types ('__constant int *' and '__generic int *')}}
#endif
#endif
void *var_void_gen;
__global char *var_glob_ch;
var_void_gen = 0 ? var_cond : var_glob_ch;
#if __OPENCL_CPP_VERSION__
// expected-error-re@-2{{incompatible operand types ('__{{constant|global|generic}} int *' and '__global char *')}}
#else
#ifdef CONSTANT
// expected-error@-5{{conditional operator with the second and third operands of type ('__constant int *' and '__global char *') which are pointers to non-overlapping address spaces}}
#else
// expected-warning-re@-7{{pointer type mismatch ('__{{global|generic}} int *' and '__global char *')}}
#endif
#endif
__local char *var_loc_ch;
var_void_gen = 0 ? var_cond : var_loc_ch;
#if __OPENCL_CPP_VERSION__
// expected-error-re@-2{{incompatible operand types ('__{{constant|global|generic}} int *' and '__local char *')}}
#else
#ifndef GENERIC
// expected-error-re@-5{{conditional operator with the second and third operands of type ('__{{global|constant}} int *' and '__local char *') which are pointers to non-overlapping address spaces}}
#else
// expected-warning@-7{{pointer type mismatch ('__generic int *' and '__local char *')}}
#endif
#endif
__constant void *var_void_const;
__constant char *var_const_ch;
var_void_const = 0 ? var_cond : var_const_ch;
#if __OPENCL_CPP_VERSION__
// expected-error-re@-2{{incompatible operand types ('__{{constant|global|generic}} int *' and '__constant char *')}}
#else
#ifndef CONSTANT
// expected-error-re@-5{{conditional operator with the second and third operands of type ('__{{global|generic}} int *' and '__constant char *') which are pointers to non-overlapping address spaces}}
#else
// expected-warning@-7{{pointer type mismatch ('__constant int *' and '__constant char *')}}
#endif
#endif
__private char *var_priv_ch;
var_void_gen = 0 ? var_cond : var_priv_ch;
#if __OPENCL_CPP_VERSION__
// expected-error-re@-2{{incompatible operand types ('__{{constant|global|generic}} int *' and '__private char *')}}
#else
#ifndef GENERIC
// expected-error-re@-5{{conditional operator with the second and third operands of type ('__{{global|constant}} int *' and '__private char *') which are pointers to non-overlapping address spaces}}
#else
// expected-warning@-7{{pointer type mismatch ('__generic int *' and '__private char *')}}
#endif
#endif
__generic char *var_gen_ch;
var_void_gen = 0 ? var_cond : var_gen_ch;
#if __OPENCL_CPP_VERSION__
// expected-error-re@-2{{incompatible operand types ('__{{constant|global|generic}} int *' and '__generic char *')}}
#else
#ifdef CONSTANT
// expected-error@-5{{conditional operator with the second and third operands of type ('__constant int *' and '__generic char *') which are pointers to non-overlapping address spaces}}
#else
// expected-warning-re@-7{{pointer type mismatch ('__{{global|generic}} int *' and '__generic char *')}}
#endif
#endif
}
void test_pointer_chains() {
AS int *AS *var_as_as_int;
AS int *AS_COMP *var_asc_as_int;
AS_INCOMP int *AS_COMP *var_asc_asn_int;
AS_COMP int *AS_COMP *var_asc_asc_int;
// Case 1:
// * address spaces of corresponded most outer pointees overlaps, their canonical types are equal
// * CVR, address spaces and canonical types of the rest of pointees are equivalent.
var_as_as_int = var_asc_as_int;
var_as_as_int = 0 ? var_as_as_int : var_asc_as_int;
// Case 2: Corresponded inner pointees has non-overlapping address spaces.
var_as_as_int = 0 ? var_as_as_int : var_asc_asn_int;
#if !__OPENCL_CPP_VERSION__
// expected-warning-re@-2{{pointer type mismatch ('__{{(generic|global|constant)}} int *__{{(generic|global|constant)}} *' and '__{{(local|global|constant)}} int *__{{(constant|local|global)}} *')}}
#else
// expected-error-re@-4{{incompatible operand types ('__{{(generic|global|constant)}} int *__{{(generic|global|constant)}} *' and '__{{(local|global|constant)}} int *__{{(constant|local|global)}} *')}}
#endif
// Case 3: Corresponded inner pointees has overlapping but not equivalent address spaces.
var_as_as_int = var_asc_asc_int;
#ifdef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-error@-3 {{assigning '__local int *__local *__private' to '__generic int *__generic *__private' changes address space of nested pointer}}
#else
// expected-error@-5 {{assigning to '__generic int *__generic *' from incompatible type '__local int *__local *__private'}}
#endif
#endif
var_as_as_int = (AS int *AS *)var_asc_asc_int;
#ifdef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-warning@-3 {{casting '__local int *__local *' to type '__generic int *__generic *' discards qualifiers in nested pointer types}}
#else
// expected-warning@-5 {{C-style cast from '__local int *__local *' to '__generic int *__generic *' changes address space of nested pointers}}
#endif
#endif
var_as_as_int = (AS int *AS *)var_asc_asn_int;
#if !__OPENCL_CPP_VERSION__
// expected-warning-re@-2 {{casting '__{{global|local|constant}} int *__{{local|constant|global}} *' to type '__{{global|constant|generic}} int *__{{global|constant|generic}} *' discards qualifiers in nested pointer types}}
#else
// expected-warning-re@-4 {{C-style cast from '__{{global|local|constant}} int *__{{local|constant|global}} *' to '__{{global|constant|generic}} int *__{{global|constant|generic}} *' changes address space of nested pointers}}
#endif
var_as_as_int = 0 ? var_as_as_int : var_asc_asc_int;
#ifdef GENERIC
#if !__OPENCL_CPP_VERSION__
// expected-warning@-3{{pointer type mismatch ('__generic int *__generic *' and '__local int *__local *')}}
#else
// expected-error@-5 {{incompatible operand types ('__generic int *__generic *' and '__local int *__local *')}}
#endif
#endif
}