Skip to content

[SYCL] Fix build issue that appeared in self-build #7881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ def SYCLSpecialClass: InheritableAttr {
def SYCLType: InheritableAttr {
let Spellings = [CXX11<"__sycl_detail__", "sycl_type">];
let Subjects = SubjectList<[CXXRecord, Enum], ErrorDiag>;
let LangOpts = [SYCLIsDevice, SYCLIsHost];
let LangOpts = [SYCLIsDevice, SilentlyIgnoreSYCLIsHost];
let Args = [EnumArgument<"Type", "SYCLType",
["accessor", "local_accessor", "spec_constant",
"specialization_id", "kernel_handler", "buffer_location",
Expand Down
10 changes: 10 additions & 0 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10710,6 +10710,11 @@ void Sema::AddSYCLDeviceHasAttr(Decl *D, const AttributeCommonInfo &CI,
}

static void handleSYCLDeviceHasAttr(Sema &S, Decl *D, const ParsedAttr &A) {
// Ignore the attribute if compiling for the host side because aspects may not
// be marked properly for such compilation
if (!S.Context.getLangOpts().SYCLIsDevice)
return;

SmallVector<Expr *, 5> Args;
for (unsigned I = 0; I < A.getNumArgs(); ++I)
Args.push_back(A.getArgAsExpr(I));
Expand Down Expand Up @@ -10751,6 +10756,11 @@ void Sema::AddSYCLUsesAspectsAttr(Decl *D, const AttributeCommonInfo &CI,
}

static void handleSYCLUsesAspectsAttr(Sema &S, Decl *D, const ParsedAttr &A) {
// Ignore the attribute if compiling for the host because aspects may not be
// marked properly for such compilation
if (!S.Context.getLangOpts().SYCLIsDevice)
return;

SmallVector<Expr *, 5> Args;
for (unsigned I = 0; I < A.getNumArgs(); ++I)
Args.push_back(A.getArgAsExpr(I));
Expand Down
9 changes: 8 additions & 1 deletion sycl/include/sycl/detail/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@
#endif
#endif

// FIXME Check for __SYCL_DEVICE_ONLY__ can be removed if implementation of
// __has_attribute is fixed to consider LangOpts when generating attributes in
// tablegen.
#if __has_attribute(sycl_special_class) && (defined __SYCL_DEVICE_ONLY__)
#define __SYCL_SPECIAL_CLASS __attribute__((sycl_special_class))
#else
#define __SYCL_SPECIAL_CLASS
#endif

#if __has_cpp_attribute(__sycl_detail__::sycl_type)
// FIXME Check for __SYCL_DEVICE_ONLY__ can be removed if implementation of
// __has_attribute is fixed to consider LangOpts when generating attributes in
// tablegen.
#if __has_cpp_attribute(__sycl_detail__::sycl_type) && \
(defined __SYCL_DEVICE_ONLY__)
#define __SYCL_TYPE(x) [[__sycl_detail__::sycl_type(x)]]
#else
#define __SYCL_TYPE(x)
Expand Down