<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54248>54248</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Constant statement expression stop being supported in clang 12 for OpenCL
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mnaczk
</td>
</tr>
</table>
<pre>
This code below was successfully compiled till Clang 11.0.1
`kernel void test()
{
const int size = ({ false; }) ? 0 : 1;
float array[size];
}`
Error log:
`<source>:4:17: error: variable length arrays are not supported in OpenCL
float array[size];
^~~~
<source>:4:17: note: initializer of 'size' is not a constant expression
<source>:3:15: note: declared here
const int size = ({ false; }) ? 0 : 1;
^
1 error generated.
Compiler returned: 1`
The above code still works for C++ and C.
### **Reproduction.**
**Not working case:**
1. Compiler: x86-64 clang 12.0.0 https://godbolt.org/z/daxzGWE39
arguments -c -x cl -emit-llvm -O0 -S -Xclang -finclude-default-header
**Working cases**
1. OpenCL with Clang 11 https://godbolt.org/z/oTKaf9a76
Compiler: x86-64 clang 11.0.1
arguments -c -x cl -emit-llvm -O0 -S -Xclang -finclude-default-header
2. C++ with Clang 12 https://godbolt.org/z/MbdErG9PP
Compiler: x86-64 clang 12.0.0
arguments -c -emit-llvm -O0 -S -Xclang -finclude-default-header
3. C with Clang 12 https://godbolt.org/z/e7Eb5185o
Compiler: x86-64 clang 12.0.0
arguments -c -x c -emit-llvm -O0 -S -Xclang -finclude-default-header
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy1VV1zmzoQ_TX4ZQcGxJd54CF2nD70c9rMpK8CLViNjDySiJP8-q4gTu20ndybuZcRAiRx9uzZXanR4qG-3koLrRYIDSp9gAO3YMe2RWu7UakHmtvtpUIBTioFa8WHHpIkiqMkiC-D-OKpL-JbNAMquNOS1qJ1AVsGrHqaLlfzC9DV6sE6kIMDKx8RgvQS_NpyBR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