[clang] [Clang/AMDGPU] Zero sized arrays not allowed in HIP device code. (PR #113470)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 23 16:32:31 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) {
+ auto *FD = dyn_cast_or_null<FunctionDecl>(CurContext);
+ if (FD && (FD->hasAttr<CUDADeviceAttr>() ||
+ FD->hasAttr<CUDAGlobalAttr>())) {
----------------
tbaederr wrote:
```suggestion
if (const auto FD = dyn_cast_if_present(...);FD && (FD->hasAttr<CUDADeviceAttr>() ||
FD->hasAttr<CUDAGlobalAttr>())) {
```
https://github.com/llvm/llvm-project/pull/113470
More information about the cfe-commits
mailing list