Skip to content

Commit bcbc2f1

Browse files
author
Erich Keane
committed
Relocate IsConst checks as requested by Prem, others
Also fixes up the issues found by the bots, including the lacking signed-off-by. Signed-off-by: Erich Keane <[email protected]>
1 parent e064bd5 commit bcbc2f1

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7062,8 +7062,8 @@ NamedDecl *Sema::ActOnVariableDeclarator(
70627062
// constexpr
70637063
if (getLangOpts().SYCLIsDevice) {
70647064
if (SCSpec == DeclSpec::SCS_static && !R.isConstant(Context))
7065-
SYCLDiagIfDeviceCode(D.getIdentifierLoc(), diag::err_sycl_restrict)
7066-
<< Sema::KernelNonConstStaticDataVariable;
7065+
SYCLDiagIfDeviceCode(D.getIdentifierLoc(), diag::err_sycl_restrict)
7066+
<< Sema::KernelNonConstStaticDataVariable;
70677067
else if (NewVD->getTSCSpec() == DeclSpec::TSCS_thread_local)
70687068
SYCLDiagIfDeviceCode(D.getIdentifierLoc(), diag::err_thread_unsupported);
70697069
}

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,10 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *D, ArrayRef<SourceLocation> Locs,
216216
if (VD->getTLSKind() != VarDecl::TLS_None)
217217
SYCLDiagIfDeviceCode(*Locs.begin(), diag::err_thread_unsupported);
218218

219-
if (VD->getStorageClass() == SC_Static &&
220-
!IsConst)
219+
if (!IsConst && VD->getStorageClass() == SC_Static)
221220
SYCLDiagIfDeviceCode(*Locs.begin(), diag::err_sycl_restrict)
222221
<< Sema::KernelNonConstStaticDataVariable;
223-
else if (VD->hasGlobalStorage() && !isa<ParmVarDecl>(VD) && !IsConst)
222+
else if (!IsConst && VD->hasGlobalStorage() && !isa<ParmVarDecl>(VD))
224223
SYCLDiagIfDeviceCode(*Locs.begin(), diag::err_sycl_restrict)
225224
<< Sema::KernelGlobalVariable;
226225
}

clang/test/SemaSYCL/prohibit-thread-local.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -fsycl-is-device -verify -fsyntax-only -std=c++17 %s
1+
// RUN: %clang_cc1 -fsycl-is-device -verify -fsyntax-only %s
22

33
thread_local const int prohobit_ns_scope = 0;
44
thread_local int prohobit_ns_scope2 = 0;
@@ -39,11 +39,12 @@ void usage() {
3939

4040
template <typename name, typename Func>
4141
__attribute__((sycl_kernel))
42-
// expected-note@+1 2{{called by}}
43-
void kernel_single_task(Func kernelFunc) { kernelFunc(); }
42+
// expected-note@+2 2{{called by}}
43+
void
44+
kernel_single_task(Func kernelFunc) { kernelFunc(); }
4445

4546
int main() {
4647
// expected-note@+1 2{{called by}}
47-
kernel_single_task<class fake_kernel>([](){ usage(); } );
48+
kernel_single_task<class fake_kernel>([]() { usage(); });
4849
return 0;
4950
}

0 commit comments

Comments
 (0)