File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -8715,16 +8715,13 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
87158715 }
87168716
87178717 // zero sized static arrays are not allowed in HIP device functions
8718- if (LangOpts.CUDAIsDevice && LangOpts.HIP) {
8719- if (FunctionDecl *FD = getCurFunctionDecl();
8720- FD &&
8721- (FD->hasAttr<CUDADeviceAttr>() || FD->hasAttr<CUDAGlobalAttr>())) {
8722- if (QualType NextTy = NewVD->getType(); NextTy->isArrayType()) {
8723- if (const ConstantArrayType *ArrayT =
8724- getASTContext().getAsConstantArrayType(NextTy);
8725- ArrayT && ArrayT->isZeroSize()) {
8726- Diag(NewVD->getLocation(), diag::err_typecheck_zero_array_size) << 2;
8727- }
8718+ if (getLangOpts().HIP &&
8719+ DeclAttrsMatchCUDAMode(getLangOpts(), getCurFunctionDecl())) {
8720+ if (QualType NextTy = NewVD->getType(); NextTy->isArrayType()) {
8721+ if (const ConstantArrayType *ArrayT =
8722+ getASTContext().getAsConstantArrayType(NextTy);
8723+ ArrayT && ArrayT->isZeroSize()) {
8724+ Diag(NewVD->getLocation(), diag::err_typecheck_zero_array_size) << 2;
87288725 }
87298726 }
87308727 }
You can’t perform that action at this time.
0 commit comments