Skip to content

Commit 7ee4272

Browse files
committed
review comment fixes
1 parent fed2349 commit 7ee4272

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8719,22 +8719,12 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
87198719
if (FunctionDecl *FD = getCurFunctionDecl();
87208720
FD &&
87218721
(FD->hasAttr<CUDADeviceAttr>() || FD->hasAttr<CUDAGlobalAttr>())) {
8722-
8723-
auto Check = [&](QualType TypeToCheck, const VarDecl *VD) {
8722+
if (QualType NextTy = NewVD->getType(); NextTy->isArrayType()) {
87248723
if (const ConstantArrayType *ArrayT =
8725-
getASTContext().getAsConstantArrayType(TypeToCheck);
8724+
getASTContext().getAsConstantArrayType(NextTy);
87268725
ArrayT && ArrayT->isZeroSize()) {
8727-
Diag(VD->getLocation(), diag::err_typecheck_zero_array_size) << 2;
8726+
Diag(NewVD->getLocation(), diag::err_typecheck_zero_array_size) << 2;
87288727
}
8729-
};
8730-
QualType NextTy = NewVD->getType();
8731-
while (NextTy->isAnyPointerType() || NextTy->isArrayType() ||
8732-
NextTy->isReferenceType()) {
8733-
if (NextTy->isArrayType()) {
8734-
Check(NextTy, NewVD);
8735-
break;
8736-
} else
8737-
NextTy = NextTy->getPointeeType();
87388728
}
87398729
}
87408730
}

clang/test/SemaHIP/zero-sized-device-array.hip

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ __global__ void global_fun() {
1111
extern __shared__ float externArray[];
1212
ZEROARR TypeDef; // expected-error {{zero-length arrays are not permitted in HIP device code}}
1313
float array[0]; // expected-error {{zero-length arrays are not permitted in HIP device code}}
14-
ZEROARR *Ptr; // expected-error {{zero-length arrays are not permitted in HIP device code}}
1514
}
1615

1716
// should not throw error for host side code.

0 commit comments

Comments
 (0)