[PATCH] D13105: [OpenCL] Enable program scope variables for OpenCL2.0

Alexey Bader via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 24 13:23:18 PDT 2015


bader added a subscriber: bader.

================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:7472-7473
@@ -7469,4 +7471,4 @@
   "sampler type cannot be used with the __local and __global address space qualifiers">;
 def err_opencl_global_invalid_addr_space : Error<
-  "global variables must have a constant address space qualifier">;
+  "program scope variables has wrong address space qualifier">;
 def err_opencl_no_main : Error<"%select{function|kernel}0 cannot be called 'main'">;
----------------
I think we can do better diagnostics. Original message hinted on way to fix that error - add 'constant' qualifier.

In our implementation we have 4 kinds of diagnostics (probably we need only 2 of them):
def err_opencl_global_invalid_addr_space : Error<
"program scope variables must reside in constant address space">;
def err_opencl20_global_invalid_addr_space : Error<
"program scope variables must reside in global or constant address space">;
def err_program_scope_variable_non_constant : Error<
"program scope variables are required to be declared in constant address space">;
def err_program_scope_variable_non_constant_or_global : Error<
"program scope variables are required to be declared either in constant or global address space">;

They used for OpenCL 1.2 and OpenCL 2.0 sources correspondingly.

================
Comment at: test/SemaOpenCL/storageclass.cl:9-11
@@ +8,5 @@
+global int G2 = 0;
+#ifndef CL20
+// expected-error at -2{{program scope variables has wrong address space qualifier}}
+#endif
+
----------------
Don't you think it's better to put OpenCL 2.0 test into separate file?


http://reviews.llvm.org/D13105





More information about the cfe-commits mailing list