Question about OpenCL language standard option

JinGu Kang jingu at
Fri Nov 29 09:32:45 PST 2013

Hi all,

I got a error from a opencl test. The test code is as following:

source code:
__kernel void test_fn(__global uint *src, __global uint4 *results) {
   const size_t SIZE = 128;
   int tid = get_global_id(0);
   if (tid*4 >= SIZE)
   __private uint sPrivateStorage[SIZE];
   for (size_t i=0 ; i<SIZE ; i++)
     sPrivateStorage[i] = src[i];
   results[tid] = vload4(tid, sPrivateStorage);

and the error message is as following:

"error: variable length arrays are not supported in OpenCL
   __private uint sPrivateStorage[SIZE];"

The problem is that 'isArraySizeVLA' function calls 
'VerifyIntegerConstantExpression' with 'S.LangOpts.GNUMode'. The OpenCL 
Language standard option does not have this option. It causes a error 
because 'AllowFold' is not set to 1. In order to fix this error, I think 
that we need to insert 'GNUMode' to  OpenCL LANGSTANDARD or modify 
sligtly checking code. How do you feel about this? I can not guarantee 
the side effect of 'GNUMode' with OpenCL. I have attached a simple patch 
as reference. If there is something wrong, please let me know.

JinGu Kang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang.patch
Type: text/x-patch
Size: 1334 bytes
Desc: not available
URL: <>

More information about the cfe-commits mailing list