Skip to content

Commit 3598dbc

Browse files
committed
[SYCL] Forbid non-const static variable uses in device code (fix intel#7)
Signed-off-by: Aleksander Fadeev <[email protected]>
1 parent 461dde6 commit 3598dbc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,14 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
211211
bool AvoidPartialAvailabilityChecks,
212212
ObjCInterfaceDecl *ClassReceiver) {
213213
if (getLangOpts().SYCLIsDevice) {
214-
if (auto VD = dyn_cast<VarDecl>(D))
214+
if (auto VD = dyn_cast<VarDecl>(D)) {
215215
if (VD->getStorageClass() == SC_Static &&
216216
!VD->getType().isConstant(Context))
217217
SYCLDiagIfDeviceCode(*Locs.begin(), diag::err_sycl_restrict)
218218
<< Sema::KernelNonConstStaticDataVariable;
219+
}
219220
}
221+
220222
SourceLocation Loc = Locs.front();
221223
if (getLangOpts().CPlusPlus && isa<FunctionDecl>(D)) {
222224
// If there were any diagnostics suppressed by template argument deduction,

0 commit comments

Comments
 (0)