================ @@ -8714,6 +8714,31 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) { } } + // zero sized static arrays are not allowed in HIP device functions + if (LangOpts.CUDAIsDevice && LangOpts.HIP) { + if (FunctionDecl *FD = getCurFunctionDecl(); + FD && + (FD->hasAttr<CUDADeviceAttr>() || FD->hasAttr<CUDAGlobalAttr>())) { + + auto Check = [&](QualType TypeToCheck, const VarDecl *VD) { + if (const ConstantArrayType *ArrayT = + getASTContext().getAsConstantArrayType(TypeToCheck); + ArrayT && ArrayT->isZeroSize()) { + Diag(VD->getLocation(), diag::err_typecheck_zero_array_size) << 2; + } + }; + QualType NextTy = NewVD->getType(); + while (NextTy->isAnyPointerType() || NextTy->isArrayType() || + NextTy->isReferenceType()) { ---------------- efriedma-quic wrote:
I'm having trouble imagining how a pointer to a zero-size array could cause issues; there isn't any way to tell in IR that pointer points to a zero-length array. https://github.com/llvm/llvm-project/pull/113470 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits