blob: a96e85c9ee247b7d6ed312ebe1f5e11c32c35dbc [file] [log] [blame]
Joey Gouly4bd55d92013-03-11 12:38:45 +00001// RUN: %clang_cc1 -verify %s
2
Aaron Ballmanb7243382013-07-23 19:30:11 +00003kernel __attribute__((vec_type_hint)) void kernel1() {} //expected-error{{'vec_type_hint' attribute takes one argument}}
Joey Gouly4bd55d92013-03-11 12:38:45 +00004
5kernel __attribute__((vec_type_hint(not_type))) void kernel2() {} //expected-error{{unknown type name 'not_type'}}
6
7kernel __attribute__((vec_type_hint(void))) void kernel3() {} //expected-error{{invalid attribute argument 'void' - expecting a vector or vectorizable scalar type}}
8
9kernel __attribute__((vec_type_hint(bool))) void kernel4() {} //expected-error{{invalid attribute argument 'bool' - expecting a vector or vectorizable scalar type}}
10
11kernel __attribute__((vec_type_hint(int))) __attribute__((vec_type_hint(float))) void kernel5() {} //expected-warning{{attribute 'vec_type_hint' is already applied with different parameters}}
12
Aaron Ballmanb7243382013-07-23 19:30:11 +000013kernel __attribute__((work_group_size_hint(8,16,32,4))) void kernel6() {} //expected-error{{'work_group_size_hint' attribute requires exactly 3 arguments}}
Joey Gouly4bd55d92013-03-11 12:38:45 +000014
15kernel __attribute__((work_group_size_hint(1,2,3))) __attribute__((work_group_size_hint(3,2,1))) void kernel7() {} //expected-warning{{attribute 'work_group_size_hint' is already applied with different parameters}}
16
Yaxun Liuaa246012018-06-12 23:58:59 +000017__attribute__((reqd_work_group_size(8,16,32))) void kernel8(){} // expected-error {{attribute 'reqd_work_group_size' can only be applied to an OpenCL kernel}}
Joey Gouly2cd9db12013-12-13 16:15:28 +000018
Yaxun Liuaa246012018-06-12 23:58:59 +000019__attribute__((work_group_size_hint(8,16,32))) void kernel9(){} // expected-error {{attribute 'work_group_size_hint' can only be applied to an OpenCL kernel}}
Joey Gouly2cd9db12013-12-13 16:15:28 +000020
Yaxun Liuaa246012018-06-12 23:58:59 +000021__attribute__((vec_type_hint(char))) void kernel10(){} // expected-error {{attribute 'vec_type_hint' can only be applied to an OpenCL kernel}}
Joey Gouly2cd9db12013-12-13 16:15:28 +000022
Joey Gouly96b94e62014-01-03 14:16:55 +000023constant int foo1 __attribute__((reqd_work_group_size(8,16,32))) = 0; // expected-error {{'reqd_work_group_size' attribute only applies to functions}}
Joey Gouly2cd9db12013-12-13 16:15:28 +000024
Joey Gouly96b94e62014-01-03 14:16:55 +000025constant int foo2 __attribute__((work_group_size_hint(8,16,32))) = 0; // expected-error {{'work_group_size_hint' attribute only applies to functions}}
Joey Gouly2cd9db12013-12-13 16:15:28 +000026
Joey Gouly96b94e62014-01-03 14:16:55 +000027constant int foo3 __attribute__((vec_type_hint(char))) = 0; // expected-error {{'vec_type_hint' attribute only applies to functions}}
Joey Goulyd4993032014-01-02 12:04:42 +000028
29void f_kernel_image2d_t( kernel image2d_t image ) { // expected-error {{'kernel' attribute only applies to functions}}
30 int __kernel x; // expected-error {{'__kernel' attribute only applies to functions}}
Joey Goulyd4993032014-01-02 12:04:42 +000031}
Joey Goulyb1d23a82014-05-19 14:41:38 +000032
33kernel __attribute__((reqd_work_group_size(1,2,0))) void kernel11(){} // expected-error {{'reqd_work_group_size' attribute must be greater than 0}}
34kernel __attribute__((reqd_work_group_size(1,0,2))) void kernel12(){} // expected-error {{'reqd_work_group_size' attribute must be greater than 0}}
35kernel __attribute__((reqd_work_group_size(0,1,2))) void kernel13(){} // expected-error {{'reqd_work_group_size' attribute must be greater than 0}}
Xiuli Panbe6da4b2017-05-04 07:31:20 +000036
Yaxun Liuaa246012018-06-12 23:58:59 +000037__attribute__((intel_reqd_sub_group_size(8))) void kernel14(){} // expected-error {{attribute 'intel_reqd_sub_group_size' can only be applied to an OpenCL kernel}}
Xiuli Panbe6da4b2017-05-04 07:31:20 +000038kernel __attribute__((intel_reqd_sub_group_size(0))) void kernel15(){} // expected-error {{'intel_reqd_sub_group_size' attribute must be greater than 0}}
39kernel __attribute__((intel_reqd_sub_group_size(8))) __attribute__((intel_reqd_sub_group_size(16))) void kernel16() {} //expected-warning{{attribute 'intel_reqd_sub_group_size' is already applied with different parameters}}
Andrew Savonichevd353e6d2018-09-06 11:54:09 +000040
Andrew Savonichev1a5623482018-09-17 10:39:46 +000041__kernel __attribute__((work_group_size_hint(8,-16,32))) void neg1() {} //expected-error{{'work_group_size_hint' attribute requires a non-negative integral compile time constant expression}}
42__kernel __attribute__((reqd_work_group_size(8,16,-32))) void neg2(){} // expected-error{{'reqd_work_group_size' attribute requires a non-negative integral compile time constant expression}}
Andrew Savonichevd353e6d2018-09-06 11:54:09 +000043
44// 4294967294 is a negative integer if treated as signed.
45// Should compile successfully, since we expect an unsigned.
46__kernel __attribute__((reqd_work_group_size(8,16,4294967294))) void ok1(){}