Skip to content

Commit a7065f4

Browse files
committed
review comments
1 parent 7ee4272 commit a7065f4

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)