3
3
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
4
4
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
5
5
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
6
+ // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
7
+ // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=+__opencl_c_program_scope_global_variables,-__opencl_c_generic_address_space,-__opencl_c_pipes
8
+ // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
9
+ // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
6
10
static constant int G1 = 0 ;
7
11
constant int G2 = 0 ;
8
12
@@ -43,19 +47,23 @@ static private float g_private_static_var = 0;
43
47
#endif
44
48
45
49
static generic float g_generic_static_var = 0 ;
46
- #if (__OPENCL_C_VERSION__ < 300 )
50
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
47
51
// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
48
52
// expected-error@-3 {{program scope variable must reside in constant address space}}
49
- #elif (__OPENCL_C_VERSION__ == 300 )
50
- #if !defined(__opencl_c_generic_address_space )
51
- // expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
52
- #endif
53
- #if !defined(__opencl_c_program_scope_global_variables )
54
- // expected-error@-9 {{program scope variable must reside in constant address space}}
55
- #endif
56
- #if defined(__opencl_c_generic_address_space ) && defined(__opencl_c_program_scope_global_variables )
57
- // expected-error@-12 {{program scope variable must reside in global or constant address space}}
58
- #endif
53
+ #elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300 )
54
+ #if !defined(__opencl_c_generic_address_space )
55
+ #if (__OPENCL_C_VERSION__ == 300 )
56
+ // expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
57
+ #elif (__OPENCL_CPP_VERSION__ == 202100 )
58
+ // expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}}
59
+ #endif
60
+ #endif
61
+ #if !defined(__opencl_c_program_scope_global_variables )
62
+ // expected-error@-13 {{program scope variable must reside in constant address space}}
63
+ #endif
64
+ #if defined(__opencl_c_generic_address_space ) && defined(__opencl_c_program_scope_global_variables )
65
+ // expected-error@-16 {{program scope variable must reside in global or constant address space}}
66
+ #endif
59
67
#endif
60
68
61
69
extern float g_implicit_extern_var ;
@@ -85,32 +93,36 @@ extern private float g_private_extern_var;
85
93
#endif
86
94
87
95
extern generic float g_generic_extern_var ;
88
- #if (__OPENCL_C_VERSION__ < 300 )
96
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
89
97
// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
90
98
// expected-error@-3 {{extern variable must reside in constant address space}}
91
- #elif (__OPENCL_C_VERSION__ == 300 )
92
- #if !defined(__opencl_c_generic_address_space )
93
- // expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
94
- #endif
95
- #if !defined(__opencl_c_program_scope_global_variables )
96
- // expected-error@-9 {{extern variable must reside in constant address space}}
97
- #endif
98
- #if defined(__opencl_c_generic_address_space ) && defined(__opencl_c_program_scope_global_variables )
99
- // expected-error@-12 {{extern variable must reside in global or constant address space}}
100
- #endif
99
+ #elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300 )
100
+ #if !defined(__opencl_c_generic_address_space )
101
+ #if (__OPENCL_C_VERSION__ == 300 )
102
+ // expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
103
+ #elif (__OPENCL_CPP_VERSION__ == 202100 )
104
+ // expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}}
105
+ #endif
106
+ #endif
107
+ #if !defined(__opencl_c_program_scope_global_variables )
108
+ // expected-error@-13 {{extern variable must reside in constant address space}}
109
+ #endif
110
+ #if defined(__opencl_c_generic_address_space ) && defined(__opencl_c_program_scope_global_variables )
111
+ // expected-error@-16 {{extern variable must reside in global or constant address space}}
112
+ #endif
101
113
#endif
102
114
103
115
void kernel foo (int x ) {
104
116
// static is not allowed at local scope before CL2.0
105
117
static int S1 = 5 ;
106
- #if __OPENCL_C_VERSION__ < 300
118
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
107
119
// expected-error@-2 {{variables in function scope cannot be declared static}}
108
120
#elif !defined(__opencl_c_program_scope_global_variables )
109
121
// expected-error@-4 {{static local variable must reside in constant address space}}
110
122
#endif
111
123
112
124
static constant int S2 = 5 ;
113
- #if __OPENCL_C_VERSION__ < 300
125
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
114
126
// expected-error@-2 {{variables in function scope cannot be declared static}}
115
127
#endif
116
128
@@ -122,7 +134,12 @@ void kernel foo(int x) {
122
134
constant int L1 = 42 ; // expected-error {{variables in the constant address space can only be declared in the outermost scope of a kernel function}}
123
135
}
124
136
125
- auto int L3 = 7 ; // expected-error-re{{OpenCL C version {{1.2|3.0}} does not support the 'auto' storage class specifier}}
137
+ auto int L3 = 7 ;
138
+ #if (__OPENCL_CPP_VERSION__ == 202100 )
139
+ // expected-error@-2{{C++ for OpenCL version 2021 does not support the 'auto' storage class specifier}}
140
+ #else
141
+ // expected-error-re@-4{{OpenCL C version {{1.2|3.0}} does not support the 'auto' storage class specifier}}
142
+ #endif
126
143
global int L4 ; // expected-error{{function scope variable cannot be declared in global address space}}
127
144
__attribute__((address_space (100 ))) int L5 ; // expected-error{{automatic variable qualified with an invalid address space}}
128
145
@@ -151,26 +168,26 @@ void f() {
151
168
}
152
169
153
170
static float l_implicit_static_var = 0 ;
154
- #if __OPENCL_C_VERSION__ < 300
171
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
155
172
// expected-error@-2 {{variables in function scope cannot be declared static}}
156
173
#elif !defined(__opencl_c_program_scope_global_variables )
157
174
// expected-error@-4 {{static local variable must reside in constant address space}}
158
175
#endif
159
176
160
177
static constant float l_constant_static_var = 0 ;
161
- #if __OPENCL_C_VERSION__ < 300
178
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
162
179
// expected-error@-2 {{variables in function scope cannot be declared static}}
163
180
#endif
164
181
165
182
static global float l_global_static_var = 0 ;
166
- #if __OPENCL_C_VERSION__ < 300
183
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
167
184
// expected-error@-2 {{variables in function scope cannot be declared static}}
168
185
#elif !defined(__opencl_c_program_scope_global_variables )
169
186
// expected-error@-4 {{static local variable must reside in constant address space}}
170
187
#endif
171
188
172
189
static local float l_local_static_var = 0 ;
173
- #if __OPENCL_C_VERSION__ < 300
190
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
174
191
// expected-error@-2 {{variables in function scope cannot be declared static}}
175
192
#elif !defined(__opencl_c_program_scope_global_variables )
176
193
// expected-error@-4 {{static local variable must reside in constant address space}}
@@ -179,7 +196,7 @@ void f() {
179
196
#endif
180
197
181
198
static private float l_private_static_var = 0 ;
182
- #if __OPENCL_C_VERSION__ < 300
199
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
183
200
// expected-error@-2 {{variables in function scope cannot be declared static}}
184
201
#elif !defined(__opencl_c_program_scope_global_variables )
185
202
// expected-error@-4 {{static local variable must reside in constant address space}}
@@ -188,23 +205,27 @@ void f() {
188
205
#endif
189
206
190
207
static generic float l_generic_static_var = 0 ;
191
- #if (__OPENCL_C_VERSION__ < 300 )
208
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
192
209
// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
193
210
// expected-error@-3 {{variables in function scope cannot be declared static}}
194
- #elif (__OPENCL_C_VERSION__ == 300 )
195
- #if !defined(__opencl_c_generic_address_space )
196
- // expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
197
- #endif
198
- #if !defined(__opencl_c_program_scope_global_variables )
199
- // expected-error@-9 {{static local variable must reside in constant address space}}
200
- #endif
201
- #if defined(__opencl_c_generic_address_space ) && defined(__opencl_c_program_scope_global_variables )
202
- // expected-error@-12 {{static local variable must reside in global or constant address space}}
203
- #endif
211
+ #elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300 )
212
+ #if !defined(__opencl_c_generic_address_space )
213
+ #if (__OPENCL_C_VERSION__ == 300 )
214
+ // expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
215
+ #elif (__OPENCL_CPP_VERSION__ == 202100 )
216
+ // expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}}
217
+ #endif
218
+ #endif
219
+ #if !defined(__opencl_c_program_scope_global_variables )
220
+ // expected-error@-13 {{static local variable must reside in constant address space}}
221
+ #endif
222
+ #if defined(__opencl_c_generic_address_space ) && defined(__opencl_c_program_scope_global_variables )
223
+ // expected-error@-16 {{static local variable must reside in global or constant address space}}
224
+ #endif
204
225
#endif
205
226
206
227
extern float l_implicit_extern_var ;
207
- #if __OPENCL_C_VERSION__ < 300
228
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
208
229
// expected-error@-2 {{extern variable must reside in constant address space}}
209
230
#elif !defined(__opencl_c_program_scope_global_variables )
210
231
// expected-error@-4 {{extern variable must reside in constant address space}}
@@ -213,14 +234,14 @@ void f() {
213
234
extern constant float l_constant_extern_var ;
214
235
215
236
extern global float l_global_extern_var ;
216
- #if __OPENCL_C_VERSION__ < 300
237
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
217
238
// expected-error@-2 {{extern variable must reside in constant address space}}
218
239
#elif !defined(__opencl_c_program_scope_global_variables )
219
240
// expected-error@-4 {{extern variable must reside in constant address space}}
220
241
#endif
221
242
222
243
extern local float l_local_extern_var ;
223
- #if __OPENCL_C_VERSION__ < 300
244
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
224
245
// expected-error@-2 {{extern variable must reside in constant address space}}
225
246
#elif !defined(__opencl_c_program_scope_global_variables )
226
247
// expected-error@-4 {{extern variable must reside in constant address space}}
@@ -229,7 +250,7 @@ void f() {
229
250
#endif
230
251
231
252
extern private float l_private_extern_var ;
232
- #if __OPENCL_C_VERSION__ < 300
253
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
233
254
// expected-error@-2 {{extern variable must reside in constant address space}}
234
255
#elif !defined(__opencl_c_program_scope_global_variables )
235
256
// expected-error@-4 {{extern variable must reside in constant address space}}
@@ -238,18 +259,22 @@ void f() {
238
259
#endif
239
260
240
261
extern generic float l_generic_extern_var ;
241
- #if (__OPENCL_C_VERSION__ < 300 )
262
+ #if (defined( __OPENCL_C_VERSION__ ) && __OPENCL_C_VERSION__ < 300 )
242
263
// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
243
264
// expected-error@-3 {{extern variable must reside in constant address space}}
244
- #elif (__OPENCL_C_VERSION__ == 300 )
245
- #if !defined(__opencl_c_generic_address_space )
246
- // expected-error@-6 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
247
- #endif
248
- #if !defined(__opencl_c_program_scope_global_variables )
249
- // expected-error@-9 {{extern variable must reside in constant address space}}
250
- #endif
251
- #if defined(__opencl_c_generic_address_space ) && defined(__opencl_c_program_scope_global_variables )
252
- // expected-error@-12 {{extern variable must reside in global or constant address space}}
253
- #endif
265
+ #elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300 )
266
+ #if !defined(__opencl_c_generic_address_space )
267
+ #if (__OPENCL_C_VERSION__ == 300 )
268
+ // expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
269
+ #elif (__OPENCL_CPP_VERSION__ == 202100 && !defined(__opencl_c_generic_address_space ))
270
+ // expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}}
271
+ #endif
272
+ #endif
273
+ #if !defined(__opencl_c_program_scope_global_variables )
274
+ // expected-error@-13 {{extern variable must reside in constant address space}}
275
+ #endif
276
+ #if defined(__opencl_c_generic_address_space ) && defined(__opencl_c_program_scope_global_variables )
277
+ // expected-error@-16 {{extern variable must reside in global or constant address space}}
278
+ #endif
254
279
#endif
255
280
}
0 commit comments