1 // RUN
: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std
=CL1.2 %s -cl-ext
=-cl_khr_3d_image_writes
2 // RUN
: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std
=CL2.0 %s
3 // RUN
: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std
=CL3.0 %s
4 // RUN
: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std
=CL3.0 %s -cl-ext
=-__opencl_c_read_write_images
5 // RUN
: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std
=clc
++2021 %s
6 // RUN
: %clang_cc1 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std
=clc
++2021 %s -cl-ext
=-__opencl_c_read_write_images
8 typedef image1d_t img1d_ro_default
; // expected-note {{previously declared 'read_only' here}}
10 typedef write_only image1d_t img1d_wo
; // expected-note {{previously declared 'write_only' here}}
11 typedef read_only image1d_t img1d_ro
;
13 #if
(__OPENCL_C_VERSION__ == 200) ||
((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__
== 300) && defined
(__opencl_c_read_write_images))
14 typedef read_write image1d_t img1d_rw
;
18 typedef read_only int IntRO
; // expected-error {{access qualifier can only be used for pipe and image type}}
20 void myWrite
(write_only image1d_t
);
21 #if
!defined
(__OPENCL_CPP_VERSION__)
22 // expected-note
@-
2 {{passing argument to parameter here
}}
23 // expected-note
@-
3 {{passing argument to parameter here
}}
25 // expected-note
@-
5 {{candidate function not viable
: no known conversion from
'__private img1d_ro
' (aka '__private __read_only image1d_t
') to
'__private __write_only image1d_t
' for
1st argument
}}
26 // expected-note
@-
6 {{candidate function not viable
: no known conversion from
'__private img1d_ro_default
' (aka '__private __read_only image1d_t
') to
'__private __write_only image1d_t
' for
1st argument
}}
29 void myRead
(read_only image1d_t
);
30 #if
!defined
(__OPENCL_CPP_VERSION__)
31 // expected-note
@-
2 {{passing argument to parameter here
}}
33 // expected-note
@-
4 {{candidate function not viable
: no known conversion from
'__private img1d_wo
' (aka '__private __write_only image1d_t
') to
'__private __read_only image1d_t
' for
1st argument
}}
36 #if
(__OPENCL_C_VERSION__ == 200) ||
((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__
== 300) && defined
(__opencl_c_read_write_images))
37 void myReadWrite
(read_write image1d_t
);
39 void myReadWrite
(read_write image1d_t
); // expected-error {{access qualifier 'read_write' cannot be used for '__read_write image1d_t' prior to OpenCL C version 2.0 or in version 3.0 and without __opencl_c_read_write_images feature}}
43 kernel void k1
(img1d_wo img
) {
45 #if
!defined
(__OPENCL_CPP_VERSION__)
46 // expected-error
@-
2 {{passing
'__private img1d_wo
' (aka '__private __write_only image1d_t
') to parameter of incompatible type
'__read_only image1d_t
'}}
48 // expected-error
@-
4 {{no matching function for call to
'myRead
'}}
52 kernel void k2
(img1d_ro img
) {
54 #if
!defined
(__OPENCL_CPP_VERSION__)
55 // expected-error
@-
2 {{passing
'__private img1d_ro
' (aka '__private __read_only image1d_t
') to parameter of incompatible type
'__write_only image1d_t
'}}
57 // expected-error
@-
4 {{no matching function for call to
'myWrite
'}}
61 kernel void k3
(img1d_wo img
) {
65 #if
(__OPENCL_C_VERSION__ == 200) ||
((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__
== 300) && defined
(__opencl_c_read_write_images))
66 kernel void k4
(img1d_rw img
) {
71 kernel void k5
(img1d_ro_default img
) {
73 #if
!defined
(__OPENCL_CPP_VERSION__)
74 // expected-error
@-
2 {{passing
'__private img1d_ro_default
' (aka '__private __read_only image1d_t
') to parameter of incompatible type
'__write_only image1d_t
'}}
76 // expected-error
@-
4 {{no matching function for call to
'myWrite
'}}
80 kernel void k6
(img1d_ro img
) {
84 kernel void k7
(read_only img1d_wo img
){} // expected-error
{{multiple access qualifiers
}}
86 kernel void k8
(write_only img1d_ro_default img
){} // expected-error
{{multiple access qualifiers
}}
88 kernel void k9
(read_only int i
){} // expected-error
{{access qualifier can only be used for pipe and image type
}}
90 kernel void k10
(read_only Int img
){} // expected-error
{{access qualifier can only be used for pipe and image type
}}
92 kernel void k11
(read_only write_only image1d_t i
){} // expected-error
{{multiple access qualifiers
}}
94 kernel void k12
(read_only read_only image1d_t i
){} // expected-warning
{{duplicate
'read_only
' declaration specifier
}}
96 #if
(__OPENCL_C_VERSION__ == 200) ||
((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__
== 300) && defined
(__opencl_c_read_write_images))
97 kernel void k13
(read_write pipe int i
){} // expected-error
{{access qualifier
'read_write
' cannot be used for
'read_only pipe int
'}}
99 kernel void k13
(__read_write image1d_t i
){} // expected-error
{{access qualifier
'__read_write
' cannot be used for
'__read_write image1d_t
' prior to OpenCL C version
2.0 or in version
3.0 and without __opencl_c_read_write_images feature
}}
102 #if defined
(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__
< 200
103 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 support
}}
106 #if
(__OPENCL_C_VERSION__ == 200) ||
((__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__
== 300) && defined
(__opencl_c_read_write_images))
107 kernel void read_write_twice_typedef
(read_write img1d_rw i
){} // expected-warning
{{duplicate
'read_write
' declaration specifier
}}
108 // expected-note
@-
94 {{previously declared
'read_write
' here
}}
111 #if __OPENCL_C_VERSION__
>= 200
112 void myPipeWrite
(write_only pipe int
); // expected-note {{passing argument to parameter here}}
113 kernel void k14
(read_only pipe int p
) {
114 myPipeWrite
(p); // expected-error {{passing '__private read_only pipe int' to parameter of incompatible type 'write_only pipe int'}}
117 kernel void pipe_ro_twice
(read_only read_only pipe int i
){} // expected-warning
{{duplicate
'read_only
' declaration specifier
}}
118 // Conflicting access qualifiers
119 kernel void pipe_ro_twice_tw
(read_write read_only read_only pipe int i
){} // expected-error
{{access qualifier
'read_write
' cannot be used for
'read_only pipe int
'}}
120 kernel void pipe_ro_wo
(read_only write_only pipe int i
){} // expected-error
{{multiple access qualifiers
}}
122 typedef read_only pipe int ROPipeInt
;
123 kernel void pipe_ro_twice_typedef
(read_only ROPipeInt i
){} // expected-warning
{{duplicate
'read_only
' declaration specifier
}}
124 // expected-note
@-
2 {{previously declared
'read_only
' here
}}
126 kernel void pass_ro_typedef_to_wo
(ROPipeInt p
) {
127 myPipeWrite
(p); // expected-error {{passing '__private ROPipeInt' (aka '__private read_only pipe int') to parameter of incompatible type 'write_only pipe int'}}
128 // expected-note
@-
16 {{passing argument to parameter here
}}
132 kernel void read_only_twice_typedef
(__read_only img1d_ro i
){} // expected-warning
{{duplicate
'__read_only
' declaration specifier
}}
133 // expected-note
@-
122 {{previously declared
'read_only
' here
}}
135 kernel void read_only_twice_default
(read_only img1d_ro_default img
){} // expected-warning
{{duplicate
'read_only
' declaration specifier
}}
136 // expected-note
@-
128 {{previously declared
'read_only
' here
}}
138 kernel void image_wo_twice
(write_only __write_only image1d_t i
){} // expected-warning
{{duplicate
'__write_only
' declaration specifier
}}
139 kernel void image_wo_twice_typedef
(write_only img1d_wo i
){} // expected-warning
{{duplicate
'write_only
' declaration specifier
}}
140 // expected-note
@-
130 {{previously declared
'write_only
' here
}}