Skip to content

Commit

Permalink
Change subject from FunctionLike to Function; add tests for subject
Browse files Browse the repository at this point in the history
FunctionLike also applies to function pointers, which is probably not
what we want.

Signed-off-by: Andrew Savonichev <[email protected]>
  • Loading branch information
Andrew Savonichev authored and vladimirlaz committed Oct 22, 2019
1 parent f786219 commit 722006c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ def SYCLDeviceIndirectlyCallable : InheritableAttr {
}
def SYCLIntelKernelArgsRestrict : InheritableAttr {
let Spellings = [ CXX11<"intel", "kernel_args_restrict"> ];
let Subjects = SubjectList<[ FunctionLike ], ErrorDiag>;
let Subjects = SubjectList<[Function], ErrorDiag>;
let LangOpts = [ SYCLIsDevice, SYCLIsHost ];
let Documentation = [ SYCLIntelKernelArgsRestrictDocs ];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
// CHECK-NEXT: ReturnsTwice (SubjectMatchRule_function)
// CHECK-NEXT: SYCLDevice (SubjectMatchRule_function)
// CHECK-NEXT: SYCLDeviceIndirectlyCallable (SubjectMatchRule_function)
// CHECK-NEXT: SYCLIntelKernelArgsRestrict (SubjectMatchRule_hasType_functionType)
// CHECK-NEXT: SYCLIntelKernelArgsRestrict (SubjectMatchRule_function)
// 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)
Expand Down
4 changes: 3 additions & 1 deletion clang/test/SemaSYCL/intel-restrict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[[intel::kernel_args_restrict]] // expected-warning{{'kernel_args_restrict' attribute ignored}}
void func_ignore() {}


struct FuncObj {
[[intel::kernel_args_restrict]]
void operator()() {}
Expand All @@ -13,6 +12,9 @@ struct FuncObj {
template <typename name, typename Func>
__attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
kernelFunc();
#ifdef CHECKDIAG
[[intel::kernel_args_restrict]] int invalid = 42; // expected-error{{'kernel_args_restrict' attribute only applies to functions}}
#endif
}

int main() {
Expand Down

0 comments on commit 722006c

Please sign in to comment.