@@ -7076,7 +7076,8 @@ NamedDecl *Sema::ActOnVariableDeclarator(
7076
7076
diag::err_thread_non_global)
7077
7077
<< DeclSpec::getSpecifierName(TSCS);
7078
7078
else if (!Context.getTargetInfo().isTLSSupported()) {
7079
- if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
7079
+ if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
7080
+ getLangOpts().SYCLIsDevice) {
7080
7081
// Postpone error emission until we've collected attributes required to
7081
7082
// figure out whether it's a host or device variable and whether the
7082
7083
// error should be ignored.
@@ -7085,14 +7086,6 @@ NamedDecl *Sema::ActOnVariableDeclarator(
7085
7086
// proper storage class for other tools to use even if we're not going
7086
7087
// to emit any code for it.
7087
7088
NewVD->setTSCSpec(TSCS);
7088
- } else if (getLangOpts().SYCLIsDevice) {
7089
- // While SYCL does not support TLS, emitting the diagnostic here
7090
- // prevents the compilation of header files with TLS declarations.
7091
- // When TLS objects are used in kernel code, they are diagnosed.
7092
- // We still need to mark the variable as TLS so it shows up in AST with
7093
- // proper storage class for other tools to use even if we're not going
7094
- // to emit any code for it.
7095
- NewVD->setTSCSpec(TSCS);
7096
7089
} else
7097
7090
Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
7098
7091
diag::err_thread_unsupported);
@@ -7102,13 +7095,10 @@ NamedDecl *Sema::ActOnVariableDeclarator(
7102
7095
7103
7096
// Static variables declared inside SYCL device code must be const or
7104
7097
// constexpr
7105
- if (getLangOpts().SYCLIsDevice) {
7098
+ if (getLangOpts().SYCLIsDevice)
7106
7099
if (SCSpec == DeclSpec::SCS_static && !R.isConstant(Context))
7107
7100
SYCLDiagIfDeviceCode(D.getIdentifierLoc(), diag::err_sycl_restrict)
7108
7101
<< Sema::KernelNonConstStaticDataVariable;
7109
- else if (NewVD->getTSCSpec() == DeclSpec::TSCS_thread_local)
7110
- SYCLDiagIfDeviceCode(D.getIdentifierLoc(), diag::err_thread_unsupported);
7111
- }
7112
7102
7113
7103
switch (D.getDeclSpec().getConstexprSpecifier()) {
7114
7104
case CSK_unspecified:
@@ -7196,13 +7186,18 @@ NamedDecl *Sema::ActOnVariableDeclarator(
7196
7186
// Handle attributes prior to checking for duplicates in MergeVarDecl
7197
7187
ProcessDeclAttributes(S, NewVD, D);
7198
7188
7199
- if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
7189
+ if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
7190
+ getLangOpts().SYCLIsDevice) {
7200
7191
if (EmitTLSUnsupportedError &&
7201
7192
((getLangOpts().CUDA && DeclAttrsMatchCUDAMode(getLangOpts(), NewVD)) ||
7202
7193
(getLangOpts().OpenMPIsDevice &&
7203
7194
OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(NewVD))))
7204
7195
Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
7205
7196
diag::err_thread_unsupported);
7197
+
7198
+ if (EmitTLSUnsupportedError && getLangOpts().SYCLIsDevice)
7199
+ SYCLDiagIfDeviceCode(D.getIdentifierLoc(), diag::err_thread_unsupported);
7200
+
7206
7201
// CUDA B.2.5: "__shared__ and __constant__ variables have implied static
7207
7202
// storage [duration]."
7208
7203
if (SC == SC_None && S->getFnParent() != nullptr &&
0 commit comments