Skip to content

Commit

Permalink
[SYCL] Forbid non-const static variable uses in device code (fix intel#7
Browse files Browse the repository at this point in the history
)

Signed-off-by: Aleksander Fadeev <[email protected]>
  • Loading branch information
fadeeval committed Feb 28, 2020
1 parent 461dde6 commit 3598dbc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,14 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
bool AvoidPartialAvailabilityChecks,
ObjCInterfaceDecl *ClassReceiver) {
if (getLangOpts().SYCLIsDevice) {
if (auto VD = dyn_cast<VarDecl>(D))
if (auto VD = dyn_cast<VarDecl>(D)) {
if (VD->getStorageClass() == SC_Static &&
!VD->getType().isConstant(Context))
SYCLDiagIfDeviceCode(*Locs.begin(), diag::err_sycl_restrict)
<< Sema::KernelNonConstStaticDataVariable;
}
}

SourceLocation Loc = Locs.front();
if (getLangOpts().CPlusPlus && isa<FunctionDecl>(D)) {
// If there were any diagnostics suppressed by template argument deduction,
Expand Down

0 comments on commit 3598dbc

Please sign in to comment.