]> granicus.if.org Git - clang/commitdiff
[OpenCL] The kernel attribute can only be used on functions.
authorJoey Gouly <joey.gouly@gmail.com>
Thu, 2 Jan 2014 12:04:42 +0000 (12:04 +0000)
committerJoey Gouly <joey.gouly@gmail.com>
Thu, 2 Jan 2014 12:04:42 +0000 (12:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198300 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Attr.td
test/SemaOpenCL/invalid-kernel-attrs.cl

index c63a1d07b2d0936180cac69b9b0ffd36a8a4302a..cd1cbb22183fddc541f469e2d9e5ccce0d77b32b 100644 (file)
@@ -432,6 +432,7 @@ def CXX11NoReturn : InheritableAttr {
 
 def OpenCLKernel : InheritableAttr {
   let Spellings = [Keyword<"__kernel">, Keyword<"kernel">];
+  let Subjects = SubjectList<[Function], ErrorDiag>;
 }
 
 def OpenCLImageAccess : Attr {
index 0da7ddf34dd984392e8bca59ae34cf4705ed1728..81ce1227cbbbfae9eb0938e361d508501b1c9933 100644 (file)
@@ -25,3 +25,8 @@ constant  int foo1 __attribute__((reqd_work_group_size(8,16,32))); // expected-e
 constant int foo2 __attribute__((work_group_size_hint(8,16,32))); // expected-error {{'work_group_size_hint' attribute only applies to functions}}
 
 constant int foo3 __attribute__((vec_type_hint(char))); // expected-error {{'vec_type_hint' attribute only applies to functions}}
+
+void f_kernel_image2d_t( kernel image2d_t image ) { // expected-error {{'kernel' attribute only applies to functions}}
+  int __kernel x; // expected-error {{'__kernel' attribute only applies to functions}}
+
+}