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
|
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-all
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-all,+__opencl_c_program_scope_global_variables
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-all,+__opencl_c_generic_address_space
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0 -cl-ext=-all,+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-all
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-all,+__opencl_c_program_scope_global_variables
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-all,+__opencl_c_generic_address_space
// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021 -cl-ext=-all,+__opencl_c_program_scope_global_variables,+__opencl_c_generic_address_space
static constant int G1 = 0;
constant int G2 = 0;
int G3 = 0;
#ifndef __opencl_c_program_scope_global_variables
// expected-error@-2 {{program scope variable must reside in constant address space}}
#endif
global int G4 = 0;
#ifndef __opencl_c_program_scope_global_variables
// expected-error@-2 {{program scope variable must reside in constant address space}}
#endif
static float g_implicit_static_var = 0;
#ifndef __opencl_c_program_scope_global_variables
// expected-error@-2 {{program scope variable must reside in constant address space}}
#endif
static constant float g_constant_static_var = 0;
static global float g_global_static_var = 0;
#ifndef __opencl_c_program_scope_global_variables
// expected-error@-2 {{program scope variable must reside in constant address space}}
#endif
static local float g_local_static_var = 0;
#ifndef __opencl_c_program_scope_global_variables
// expected-error@-2 {{program scope variable must reside in constant address space}}
#else
// expected-error@-4 {{program scope variable must reside in global or constant address space}}
#endif
static private float g_private_static_var = 0;
#ifndef __opencl_c_program_scope_global_variables
// expected-error@-2 {{program scope variable must reside in constant address space}}
#else
// expected-error@-4 {{program scope variable must reside in global or constant address space}}
#endif
static generic float g_generic_static_var = 0;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
// expected-error@-3 {{program scope variable must reside in constant address space}}
#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
#if !defined(__opencl_c_generic_address_space)
#if (__OPENCL_C_VERSION__ == 300)
// expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
#elif (__OPENCL_CPP_VERSION__ == 202100)
// expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}}
#endif
#endif
#if !defined(__opencl_c_program_scope_global_variables)
// expected-error@-13 {{program scope variable must reside in constant address space}}
#endif
#if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables)
// expected-error@-16 {{program scope variable must reside in global or constant address space}}
#endif
#endif
extern float g_implicit_extern_var;
#ifndef __opencl_c_program_scope_global_variables
// expected-error@-2 {{extern variable must reside in constant address space}}
#endif
extern constant float g_constant_extern_var;
extern global float g_global_extern_var;
#ifndef __opencl_c_program_scope_global_variables
// expected-error@-2 {{extern variable must reside in constant address space}}
#endif
extern local float g_local_extern_var;
#ifndef __opencl_c_program_scope_global_variables
// expected-error@-2 {{extern variable must reside in constant address space}}
#else
// expected-error@-4 {{extern variable must reside in global or constant address space}}
#endif
extern private float g_private_extern_var;
#ifndef __opencl_c_program_scope_global_variables
// expected-error@-2 {{extern variable must reside in constant address space}}
#else
// expected-error@-4 {{extern variable must reside in global or constant address space}}
#endif
extern generic float g_generic_extern_var;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
// expected-error@-3 {{extern variable must reside in constant address space}}
#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
#if !defined(__opencl_c_generic_address_space)
#if (__OPENCL_C_VERSION__ == 300)
// expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
#elif (__OPENCL_CPP_VERSION__ == 202100)
// expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}}
#endif
#endif
#if !defined(__opencl_c_program_scope_global_variables)
// expected-error@-13 {{extern variable must reside in constant address space}}
#endif
#if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables)
// expected-error@-16 {{extern variable must reside in global or constant address space}}
#endif
#endif
void kernel foo(int x) {
// static is not allowed at local scope before CL2.0
static int S1 = 5;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{variables in function scope cannot be declared static}}
#elif !defined(__opencl_c_program_scope_global_variables)
// expected-error@-4 {{static local variable must reside in constant address space}}
#endif
static constant int S2 = 5;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{variables in function scope cannot be declared static}}
#endif
constant int L1 = 0;
local int L2;
if (true) {
local int L1; // expected-error {{variables in the local address space can only be declared in the outermost scope of a kernel function}}
constant int L1 = 42; // expected-error {{variables in the constant address space can only be declared in the outermost scope of a kernel function}}
}
auto int L3 = 7;
#if (__OPENCL_CPP_VERSION__ == 202100)
// expected-error@-2{{C++ for OpenCL version 2021 does not support the 'auto' storage class specifier}}
#else
// expected-error-re@-4{{OpenCL C version {{1.2|3.0}} does not support the 'auto' storage class specifier}}
#endif
global int L4; // expected-error{{function scope variable cannot be declared in global address space}}
__attribute__((address_space(100))) int L5; // expected-error{{automatic variable qualified with an invalid address space}}
constant int L6 = x; // expected-error {{initializer element is not a compile-time constant}}
global int *constant L7 = &G4;
private int *constant L8 = &x; // expected-error {{initializer element is not a compile-time constant}}
constant int *constant L9 = &L1;
local int *constant L10 = &L2; // expected-error {{initializer element is not a compile-time constant}}
}
static void kernel bar(void) { // expected-error{{kernel functions cannot be declared static}}
}
void f(void) {
constant int L1 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}}
local int L2; // expected-error{{non-kernel function variable cannot be declared in local address space}}
global int L3; // expected-error{{function scope variable cannot be declared in global address space}}
__attribute__((address_space(100))) int L4; // expected-error{{automatic variable qualified with an invalid address space}}
{
constant int L1 = 0; // expected-error{{non-kernel function variable cannot be declared in constant address space}}
local int L2; // expected-error{{non-kernel function variable cannot be declared in local address space}}
global int L3; // expected-error{{function scope variable cannot be declared in global address space}}
__attribute__((address_space(100))) int L4; // expected-error{{automatic variable qualified with an invalid address space}}
}
static float l_implicit_static_var = 0;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{variables in function scope cannot be declared static}}
#elif !defined(__opencl_c_program_scope_global_variables)
// expected-error@-4 {{static local variable must reside in constant address space}}
#endif
static constant float l_constant_static_var = 0;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{variables in function scope cannot be declared static}}
#endif
static global float l_global_static_var = 0;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{variables in function scope cannot be declared static}}
#elif !defined(__opencl_c_program_scope_global_variables)
// expected-error@-4 {{static local variable must reside in constant address space}}
#endif
static local float l_local_static_var = 0;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{variables in function scope cannot be declared static}}
#elif !defined(__opencl_c_program_scope_global_variables)
// expected-error@-4 {{static local variable must reside in constant address space}}
#elif defined(__opencl_c_program_scope_global_variables)
// expected-error@-6 {{static local variable must reside in global or constant address space}}
#endif
static private float l_private_static_var = 0;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{variables in function scope cannot be declared static}}
#elif !defined(__opencl_c_program_scope_global_variables)
// expected-error@-4 {{static local variable must reside in constant address space}}
#elif defined(__opencl_c_program_scope_global_variables)
// expected-error@-6 {{static local variable must reside in global or constant address space}}
#endif
static generic float l_generic_static_var = 0;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
// expected-error@-3 {{variables in function scope cannot be declared static}}
#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
#if !defined(__opencl_c_generic_address_space)
#if (__OPENCL_C_VERSION__ == 300)
// expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
#elif (__OPENCL_CPP_VERSION__ == 202100)
// expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}}
#endif
#endif
#if !defined(__opencl_c_program_scope_global_variables)
// expected-error@-13 {{static local variable must reside in constant address space}}
#endif
#if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables)
// expected-error@-16 {{static local variable must reside in global or constant address space}}
#endif
#endif
extern float l_implicit_extern_var;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{extern variable must reside in constant address space}}
#elif !defined(__opencl_c_program_scope_global_variables)
// expected-error@-4 {{extern variable must reside in constant address space}}
#endif
extern constant float l_constant_extern_var;
extern global float l_global_extern_var;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{extern variable must reside in constant address space}}
#elif !defined(__opencl_c_program_scope_global_variables)
// expected-error@-4 {{extern variable must reside in constant address space}}
#endif
extern local float l_local_extern_var;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{extern variable must reside in constant address space}}
#elif !defined(__opencl_c_program_scope_global_variables)
// expected-error@-4 {{extern variable must reside in constant address space}}
#elif defined(__opencl_c_program_scope_global_variables)
// expected-error@-6 {{extern variable must reside in global or constant address space}}
#endif
extern private float l_private_extern_var;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{extern variable must reside in constant address space}}
#elif !defined(__opencl_c_program_scope_global_variables)
// expected-error@-4 {{extern variable must reside in constant address space}}
#elif defined(__opencl_c_program_scope_global_variables)
// expected-error@-6 {{extern variable must reside in global or constant address space}}
#endif
extern generic float l_generic_extern_var;
#if (defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300)
// expected-error@-2 {{OpenCL C version 1.2 does not support the 'generic' type qualifier}}
// expected-error@-3 {{extern variable must reside in constant address space}}
#elif (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
#if !defined(__opencl_c_generic_address_space)
#if (__OPENCL_C_VERSION__ == 300)
// expected-error@-7 {{OpenCL C version 3.0 does not support the 'generic' type qualifier}}
#elif (__OPENCL_CPP_VERSION__ == 202100 && !defined(__opencl_c_generic_address_space))
// expected-error@-9 {{C++ for OpenCL version 2021 does not support the 'generic' type qualifier}}
#endif
#endif
#if !defined(__opencl_c_program_scope_global_variables)
// expected-error@-13 {{extern variable must reside in constant address space}}
#endif
#if defined(__opencl_c_generic_address_space) && defined(__opencl_c_program_scope_global_variables)
// expected-error@-16 {{extern variable must reside in global or constant address space}}
#endif
#endif
}
|