Remove building with NOCRYPTO option
[minix.git] / external / bsd / llvm / dist / clang / test / SemaOpenCL / address-spaces-conversions-cl2.0.cl
blob50363f23a9004436adb2120b51ddc53581a61dd6
1 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DCONSTANT -cl-std=CL2.0
2 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGLOBAL -cl-std=CL2.0
3 // RUN: %clang_cc1 %s -ffake-address-space-map -verify -pedantic -fsyntax-only -DGENERIC -cl-std=CL2.0
5 /* OpenCLC v2.0 adds a set of restrictions for conversions between pointers to
6 * different address spaces, mainly described in Sections 6.5.5 and 6.5.6.
8 * It adds notion of overlapping address spaces. The main differention is that
9 * an unnamed address space is added, called '__generic'. Pointers to the
10 * generic address space can be interchangabley used with pointers to any
11 * other address space except for __constant address space (Section 6.5.5).
13 * Based on this there are 3 sets of tests: __generic, named (__global in this
14 * case), and __constant, that should cover all program paths for CL address
15 * space conversions used in initialisations, assignments, casts, comparisons
16 * and arithmetic operations.
19 #ifdef GENERIC
20 #define AS generic
21 #endif
23 #ifdef GLOBAL
24 #define AS global
25 #endif
27 #ifdef CONSTANT
28 #define AS constant
29 #endif
31 void f_glob(global int *arg_glob) {}
32 #ifndef GLOBAL
33 // expected-note@-2{{passing argument to parameter 'arg_glob' here}}
34 #endif
36 void f_loc(local int *arg_loc) {
37 } // expected-note@-1{{passing argument to parameter 'arg_loc' here}}
39 void f_const(constant int *arg_const) {}
40 #ifndef CONSTANT
41 // expected-note@-2{{passing argument to parameter 'arg_const' here}}
42 #endif
44 void f_priv(private int *arg_priv) {
45 } // expected-note@-1{{passing argument to parameter 'arg_priv' here}}
47 void f_gen(generic int *arg_gen) {}
48 #ifdef CONSTANT
49 // expected-note@-2{{passing argument to parameter 'arg_gen' here}}
50 #endif
52 void test_conversion(global int *arg_glob, local int *arg_loc,
53 constant int *arg_const, private int *arg_priv,
54 generic int *arg_gen) {
56 AS int *var_init1 = arg_glob;
57 #ifdef CONSTANT
58 // expected-error@-2{{initializing '__constant int *' with an expression of type '__global int *' changes address space of pointer}}
59 #endif
61 AS int *var_init2 = arg_loc;
62 #ifndef GENERIC
63 // expected-error-re@-2{{initializing '__{{global|constant}} int *' with an expression of type '__local int *' changes address space of pointer}}
64 #endif
66 AS int *var_init3 = arg_const;
67 #ifndef CONSTANT
68 // expected-error-re@-2{{initializing '__{{global|generic}} int *' with an expression of type '__constant int *' changes address space of pointer}}
69 #endif
71 AS int *var_init4 = arg_priv;
72 #ifndef GENERIC
73 // expected-error-re@-2{{initializing '__{{global|constant}} int *' with an expression of type 'int *' changes address space of pointer}}
74 #endif
76 AS int *var_init5 = arg_gen;
77 #ifndef GENERIC
78 // expected-error-re@-2{{initializing '__{{global|constant}} int *' with an expression of type '__generic int *' changes address space of pointer}}
79 #endif
81 AS int *var_cast1 = (AS int *)arg_glob;
82 #ifdef CONSTANT
83 // expected-error@-2{{casting '__global int *' to type '__constant int *' changes address space of pointer}}
84 #endif
86 AS int *var_cast2 = (AS int *)arg_loc;
87 #ifndef GENERIC
88 // expected-error-re@-2{{casting '__local int *' to type '__{{global|constant}} int *' changes address space of pointer}}
89 #endif
91 AS int *var_cast3 = (AS int *)arg_const;
92 #ifndef CONSTANT
93 // expected-error-re@-2{{casting '__constant int *' to type '__{{global|generic}} int *' changes address space of pointer}}
94 #endif
96 AS int *var_cast4 = (AS int *)arg_priv;
97 #ifndef GENERIC
98 // expected-error-re@-2{{casting 'int *' to type '__{{global|constant}} int *' changes address space of pointer}}
99 #endif
101 AS int *var_cast5 = (AS int *)arg_gen;
102 #ifdef CONSTANT
103 // expected-error@-2{{casting '__generic int *' to type '__constant int *' changes address space of pointer}}
104 #endif
106 AS int *var_impl;
107 var_impl = arg_glob;
108 #ifdef CONSTANT
109 // expected-error@-2{{assigning '__global int *' to '__constant int *' changes address space of pointer}}
110 #endif
112 var_impl = arg_loc;
113 #ifndef GENERIC
114 // expected-error-re@-2{{assigning '__local int *' to '__{{global|constant}} int *' changes address space of pointer}}
115 #endif
117 var_impl = arg_const;
118 #ifndef CONSTANT
119 // expected-error-re@-2{{assigning '__constant int *' to '__{{global|generic}} int *' changes address space of pointer}}
120 #endif
122 var_impl = arg_priv;
123 #ifndef GENERIC
124 // expected-error-re@-2{{assigning 'int *' to '__{{global|constant}} int *' changes address space of pointer}}
125 #endif
127 var_impl = arg_gen;
128 #ifndef GENERIC
129 // expected-error-re@-2{{assigning '__generic int *' to '__{{global|constant}} int *' changes address space of pointer}}
130 #endif
132 var_cast1 = (AS int *)arg_glob;
133 #ifdef CONSTANT
134 // expected-error@-2{{casting '__global int *' to type '__constant int *' changes address space of pointer}}
135 #endif
137 var_cast2 = (AS int *)arg_loc;
138 #ifndef GENERIC
139 // expected-error-re@-2{{casting '__local int *' to type '__{{global|constant}} int *' changes address space of pointer}}
140 #endif
142 var_cast3 = (AS int *)arg_const;
143 #ifndef CONSTANT
144 // expected-error-re@-2{{casting '__constant int *' to type '__{{global|generic}} int *' changes address space of pointer}}
145 #endif
147 var_cast4 = (AS int *)arg_priv;
148 #ifndef GENERIC
149 // expected-error-re@-2{{casting 'int *' to type '__{{global|constant}} int *' changes address space of pointer}}
150 #endif
152 var_cast5 = (AS int *)arg_gen;
153 #ifdef CONSTANT
154 // expected-error@-2{{casting '__generic int *' to type '__constant int *' changes address space of pointer}}
155 #endif
157 AS int *var_cmp;
158 int b = var_cmp != arg_glob;
159 #ifdef CONSTANT
160 // expected-error@-2{{comparison between ('__constant int *' and '__global int *') which are pointers to non-overlapping address spaces}}
161 #endif
163 b = var_cmp != arg_loc;
164 #ifndef GENERIC
165 // expected-error-re@-2{{comparison between ('__{{global|constant}} int *' and '__local int *') which are pointers to non-overlapping address spaces}}
166 #endif
168 b = var_cmp == arg_const;
169 #ifndef CONSTANT
170 // expected-error-re@-2{{comparison between ('__{{global|generic}} int *' and '__constant int *') which are pointers to non-overlapping address spaces}}
171 #endif
173 b = var_cmp <= arg_priv;
174 #ifndef GENERIC
175 // expected-error-re@-2{{comparison between ('__{{global|constant}} int *' and 'int *') which are pointers to non-overlapping address spaces}}
176 #endif
178 b = var_cmp >= arg_gen;
179 #ifdef CONSTANT
180 // expected-error@-2{{comparison between ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}}
181 #endif
183 AS int *var_sub;
184 b = var_sub - arg_glob;
185 #ifdef CONSTANT
186 // expected-error@-2{{arithmetic operation with operands of type ('__constant int *' and '__global int *') which are pointers to non-overlapping address spaces}}
187 #endif
189 b = var_sub - arg_loc;
190 #ifndef GENERIC
191 // expected-error-re@-2{{arithmetic operation with operands of type ('__{{global|constant}} int *' and '__local int *') which are pointers to non-overlapping address spaces}}
192 #endif
194 b = var_sub - arg_const;
195 #ifndef CONSTANT
196 // expected-error-re@-2{{arithmetic operation with operands of type ('__{{global|generic}} int *' and '__constant int *') which are pointers to non-overlapping address spaces}}
197 #endif
199 b = var_sub - arg_priv;
200 #ifndef GENERIC
201 // expected-error-re@-2{{arithmetic operation with operands of type ('__{{global|constant}} int *' and 'int *') which are pointers to non-overlapping address spaces}}
202 #endif
204 b = var_sub - arg_gen;
205 #ifdef CONSTANT
206 // expected-error@-2{{arithmetic operation with operands of type ('__constant int *' and '__generic int *') which are pointers to non-overlapping address spaces}}
207 #endif
209 f_glob(var_sub);
210 #ifndef GLOBAL
211 // expected-error-re@-2{{passing '__{{constant|generic}} int *' to parameter of type '__global int *' changes address space of pointer}}
212 #endif
214 f_loc(var_sub); // expected-error-re{{passing '__{{global|constant|generic}} int *' to parameter of type '__local int *' changes address space of pointer}}
216 f_const(var_sub);
217 #ifndef CONSTANT
218 // expected-error-re@-2{{passing '__{{global|generic}} int *' to parameter of type '__constant int *' changes address space of pointer}}
219 #endif
221 f_priv(var_sub); // expected-error-re{{passing '__{{global|constant|generic}} int *' to parameter of type 'int *' changes address space of pointer}}
223 f_gen(var_sub);
224 #ifdef CONSTANT
225 // expected-error@-2{{passing '__constant int *' to parameter of type '__generic int *' changes address space of pointer}}
226 #endif