| 1 | // RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL1.2 %s |
| 2 | // RUN: %clang_cc1 -verify -pedantic -fsyntax-only -cl-std=CL2.0 %s |
| 3 | |
| 4 | typedef image1d_t img1d_ro_default; // expected-note {{previously declared 'read_only' here}} |
| 5 | |
| 6 | typedef write_only image1d_t img1d_wo; // expected-note {{previously declared 'write_only' here}} |
| 7 | typedef read_only image1d_t img1d_ro; |
| 8 | |
| 9 | #if __OPENCL_C_VERSION__ >= 200 |
| 10 | typedef read_write image1d_t img1d_rw; |
| 11 | #endif |
| 12 | |
| 13 | typedef int Int; |
| 14 | typedef read_only int IntRO; // expected-error {{access qualifier can only be used for pipe and image type}} |
| 15 | |
| 16 | |
| 17 | void myWrite(write_only image1d_t); // expected-note {{passing argument to parameter here}} expected-note {{passing argument to parameter here}} |
| 18 | void myRead(read_only image1d_t); // expected-note {{passing argument to parameter here}} |
| 19 | |
| 20 | #if __OPENCL_C_VERSION__ >= 200 |
| 21 | void myReadWrite(read_write image1d_t); |
| 22 | #else |
| 23 | void myReadWrite(read_write image1d_t); // expected-error {{access qualifier 'read_write' can not be used for '__read_write image1d_t' prior to OpenCL version 2.0}} |
| 24 | #endif |
| 25 | |
| 26 | |
| 27 | kernel void k1(img1d_wo img) { |
| 28 | myRead(img); // expected-error {{passing 'img1d_wo' (aka '__write_only image1d_t') to parameter of incompatible type '__read_only image1d_t'}} |
| 29 | } |
| 30 | |
| 31 | kernel void k2(img1d_ro img) { |
| 32 | myWrite(img); // expected-error {{passing 'img1d_ro' (aka '__read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}} |
| 33 | } |
| 34 | |
| 35 | kernel void k3(img1d_wo img) { |
| 36 | myWrite(img); |
| 37 | } |
| 38 | |
| 39 | #if __OPENCL_C_VERSION__ >= 200 |
| 40 | kernel void k4(img1d_rw img) { |
| 41 | myReadWrite(img); |
| 42 | } |
| 43 | #endif |
| 44 | |
| 45 | kernel void k5(img1d_ro_default img) { |
| 46 | myWrite(img); // expected-error {{passing 'img1d_ro_default' (aka '__read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}} |
| 47 | } |
| 48 | |
| 49 | kernel void k6(img1d_ro img) { |
| 50 | myRead(img); |
| 51 | } |
| 52 | |
| 53 | kernel void k7(read_only img1d_wo img){} // expected-error {{multiple access qualifiers}} |
| 54 | |
| 55 | kernel void k8(write_only img1d_ro_default img){} // expected-error {{multiple access qualifiers}} |
| 56 | |
| 57 | kernel void k9(read_only int i){} // expected-error{{access qualifier can only be used for pipe and image type}} |
| 58 | |
| 59 | kernel void k10(read_only Int img){} // expected-error {{access qualifier can only be used for pipe and image type}} |
| 60 | |
| 61 | kernel void k11(read_only write_only image1d_t i){} // expected-error{{multiple access qualifiers}} |
| 62 | |
| 63 | kernel void k12(read_only read_only image1d_t i){} // expected-warning {{duplicate 'read_only' declaration specifier}} |
| 64 | |
| 65 | #if __OPENCL_C_VERSION__ >= 200 |
| 66 | kernel void k13(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'read_only pipe int'}} |
| 67 | #else |
| 68 | kernel void k13(__read_write image1d_t i){} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' prior to OpenCL version 2.0}} |
| 69 | #endif |
| 70 | |
| 71 | #if __OPENCL_C_VERSION__ >= 200 |
| 72 | void myPipeWrite(write_only pipe int); // expected-note {{passing argument to parameter here}} |
| 73 | kernel void k14(read_only pipe int p) { |
| 74 | myPipeWrite(p); // expected-error {{passing 'read_only pipe int' to parameter of incompatible type 'write_only pipe int'}} |
| 75 | } |
| 76 | #endif |
| 77 | |
| 78 | #if __OPENCL_C_VERSION__ < 200 |
| 79 | kernel void test_image3d_wo(write_only image3d_t img) {} // expected-error {{use of type '__write_only image3d_t' requires cl_khr_3d_image_writes extension to be enabled}} |
| 80 | #endif |
| 81 | |
| 82 | #if __OPENCL_C_VERSION__ >= 200 |
| 83 | kernel void read_write_twice_typedef(read_write img1d_rw i){} // expected-warning {{duplicate 'read_write' declaration specifier}} |
| 84 | // expected-note@-74 {{previously declared 'read_write' here}} |
| 85 | |
| 86 | kernel void pipe_ro_twice(read_only read_only pipe int i){} // expected-warning{{duplicate 'read_only' declaration specifier}} |
| 87 | // Conflicting access qualifiers |
| 88 | kernel void pipe_ro_twice_tw(read_write read_only read_only pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'read_only pipe int'}} |
| 89 | kernel void pipe_ro_wo(read_only write_only pipe int i){} // expected-error{{multiple access qualifiers}} |
| 90 | |
| 91 | typedef read_only pipe int ROPipeInt; |
| 92 | kernel void pipe_ro_twice_typedef(read_only ROPipeInt i){} // expected-warning{{duplicate 'read_only' declaration specifier}} |
| 93 | // expected-note@-2 {{previously declared 'read_only' here}} |
| 94 | |
| 95 | kernel void pass_ro_typedef_to_wo(ROPipeInt p) { |
| 96 | myPipeWrite(p); // expected-error {{passing 'ROPipeInt' (aka 'read_only pipe int') to parameter of incompatible type 'write_only pipe int'}} |
| 97 | // expected-note@-25 {{passing argument to parameter here}} |
| 98 | } |
| 99 | #endif |
| 100 | |
| 101 | kernel void read_only_twice_typedef(__read_only img1d_ro i){} // expected-warning {{duplicate '__read_only' declaration specifier}} |
| 102 | // expected-note@-95 {{previously declared 'read_only' here}} |
| 103 | |
| 104 | kernel void read_only_twice_default(read_only img1d_ro_default img){} // expected-warning {{duplicate 'read_only' declaration specifier}} |
| 105 | // expected-note@-101 {{previously declared 'read_only' here}} |
| 106 | |
| 107 | kernel void image_wo_twice(write_only __write_only image1d_t i){} // expected-warning {{duplicate '__write_only' declaration specifier}} |
| 108 | kernel void image_wo_twice_typedef(write_only img1d_wo i){} // expected-warning {{duplicate 'write_only' declaration specifier}} |
| 109 | // expected-note@-103 {{previously declared 'write_only' here}} |
| 110 | |
| 111 | |