From f1d20ee209450aea8c0a382e8312ffa0932d7003 Mon Sep 17 00:00:00 2001 From: Vladimir Lazarev Date: Fri, 28 Dec 2018 19:07:01 +0300 Subject: [PATCH] [SYCL] Add SYCL kernel attribute to clang. Signed-off-by: Vladimir Lazarev --- clang/include/clang/Basic/Attr.td | 7 +++++++ clang/lib/Sema/SemaDeclAttr.cpp | 3 +++ .../Misc/pragma-attribute-supported-attributes-list.test | 1 + clang/test/SemaSYCL/kernel-attribute.cpp | 5 +++++ 4 files changed, 16 insertions(+) create mode 100644 clang/test/SemaSYCL/kernel-attribute.cpp diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 81c9c594d0e06..c74ebc0bd9a9c 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -991,6 +991,13 @@ def SYCLDevice : InheritableAttr { let Documentation = [Undocumented]; } +def SYCLKernel : InheritableAttr { + let Spellings = [GNU<"sycl_kernel">]; + let Subjects = SubjectList<[Function]>; + let LangOpts = [SYCL]; + let Documentation = [Undocumented]; +} + def C11NoReturn : InheritableAttr { let Spellings = [Keyword<"_Noreturn">]; let Subjects = SubjectList<[Function], ErrorDiag>; diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 63501d92915ad..475a948965a5e 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -6280,6 +6280,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, case ParsedAttr::AT_Flatten: handleSimpleAttribute(S, D, AL); break; + case ParsedAttr::AT_SYCLKernel: + handleSimpleAttribute(S, D, AL); + break; case ParsedAttr::AT_Format: handleFormatAttr(S, D, AL); break; diff --git a/clang/test/Misc/pragma-attribute-supported-attributes-list.test b/clang/test/Misc/pragma-attribute-supported-attributes-list.test index 9809fa4df552b..154ed8584d207 100644 --- a/clang/test/Misc/pragma-attribute-supported-attributes-list.test +++ b/clang/test/Misc/pragma-attribute-supported-attributes-list.test @@ -117,6 +117,7 @@ // CHECK-NEXT: ReturnsNonNull (SubjectMatchRule_objc_method, SubjectMatchRule_function) // CHECK-NEXT: ReturnsTwice (SubjectMatchRule_function) // CHECK-NEXT: SYCLDevice (SubjectMatchRule_function, SubjectMatchRule_variable) +// CHECK-NEXT: SYCLKernel (SubjectMatchRule_function) // CHECK-NEXT: ScopedLockable (SubjectMatchRule_record) // CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property) // CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member) diff --git a/clang/test/SemaSYCL/kernel-attribute.cpp b/clang/test/SemaSYCL/kernel-attribute.cpp new file mode 100644 index 0000000000000..cba10c2f90db3 --- /dev/null +++ b/clang/test/SemaSYCL/kernel-attribute.cpp @@ -0,0 +1,5 @@ +// RUN: %clang_cc1 -fsycl-is-device -fsyntax-only -fcxx-exceptions -verify -pedantic -std=c++11 %s +// expected-no-diagnostics + +__attribute((sycl_kernel)) void foo() { +}