File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -8715,11 +8715,12 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
87158715 }
87168716
87178717 // zero sized static arrays are not allowed in HIP device functions
8718- if (getLangOpts().HIP &&
8719- DeclAttrsMatchCUDAMode(getLangOpts(), getCurFunctionDecl())) {
8720- if (QualType NextTy = NewVD->getType(); NextTy->isArrayType()) {
8718+ if (getLangOpts().HIP && LangOpts.CUDAIsDevice) {
8719+ if (FunctionDecl *FD = getCurFunctionDecl();
8720+ FD &&
8721+ (FD->hasAttr<CUDADeviceAttr>() || FD->hasAttr<CUDAGlobalAttr>())) {
87218722 if (const ConstantArrayType *ArrayT =
8722- getASTContext().getAsConstantArrayType(NextTy );
8723+ getASTContext().getAsConstantArrayType(T );
87238724 ArrayT && ArrayT->isZeroSize()) {
87248725 Diag(NewVD->getLocation(), diag::err_typecheck_zero_array_size) << 2;
87258726 }
Original file line number Diff line number Diff line change 77
88typedef float ZEROARR[0];
99
10+ float global_array[0 ];
11+
1012__global__ void global_fun () {
1113 extern __shared__ float externArray[];
1214 ZEROARR TypeDef; // expected-error {{zero-length arrays are not permitted in HIP device code}}
You can’t perform that action at this time.
0 commit comments