[clang] [Clang/AMDGPU] Zero sized arrays not allowed in HIP device code. (PR #113470)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 23 16:53:11 PDT 2024
================
@@ -2259,6 +2259,17 @@ QualType Sema::BuildArrayType(QualType T, ArraySizeModifier ASM,
isSFINAEContext() ? diag::err_typecheck_zero_array_size
: diag::ext_typecheck_zero_array_size)
<< 0 << ArraySize->getSourceRange();
+
+ // zero sized static arrays are not allowed in HIP device functions
+ if (LangOpts.HIP && LangOpts.CUDAIsDevice) {
----------------
efriedma-quic wrote:
I'm not sure you're diagnosing this in the right place; BuildArrayType gets called at the point we parse the type, not the variable, so you can easily avoid the diagnostic using something like the following:
```
typedef float floatarr[0];
__global__ void global_fun() {
floatarr array;
}
```
https://github.com/llvm/llvm-project/pull/113470
More information about the cfe-commits
mailing list