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
4 typedef image1d_t img1d_ro_default
; // expected-note {{previously declared 'read_only' here}}
6 typedef write_only image1d_t img1d_wo
; // expected-note {{previously declared 'write_only' here}}
7 typedef read_only image1d_t img1d_ro
;
9 #if __OPENCL_C_VERSION__
>= 200
10 typedef read_write image1d_t img1d_rw
;
14 typedef read_only int IntRO
; // expected-error {{access qualifier can only be used for pipe and image type}}
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}}
20 #if __OPENCL_C_VERSION__
>= 200
21 void myReadWrite
(read_write image1d_t
);
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}}
27 kernel void k1
(img1d_wo img
) {
28 myRead
(img); // expected-error {{passing '__private img1d_wo' (aka '__private __write_only image1d_t') to parameter of incompatible type '__read_only image1d_t'}}
31 kernel void k2
(img1d_ro img
) {
32 myWrite
(img); // expected-error {{passing '__private img1d_ro' (aka '__private __read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}}
35 kernel void k3
(img1d_wo img
) {
39 #if __OPENCL_C_VERSION__
>= 200
40 kernel void k4
(img1d_rw img
) {
45 kernel void k5
(img1d_ro_default img
) {
46 myWrite
(img); // expected-error {{passing '__private img1d_ro_default' (aka '__private __read_only image1d_t') to parameter of incompatible type '__write_only image1d_t'}}
49 kernel void k6
(img1d_ro img
) {
53 kernel void k7
(read_only img1d_wo img
){} // expected-error
{{multiple access qualifiers
}}
55 kernel void k8
(write_only img1d_ro_default img
){} // expected-error
{{multiple access qualifiers
}}
57 kernel void k9
(read_only int i
){} // expected-error
{{access qualifier can only be used for pipe and image type
}}
59 kernel void k10
(read_only Int img
){} // expected-error
{{access qualifier can only be used for pipe and image type
}}
61 kernel void k11
(read_only write_only image1d_t i
){} // expected-error
{{multiple access qualifiers
}}
63 kernel void k12
(read_only read_only image1d_t i
){} // expected-warning
{{duplicate
'read_only
' declaration specifier
}}
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
'}}
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}}
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 '__private read_only pipe int' to parameter of incompatible type 'write_only pipe int'}}
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
}}
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
}}
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
}}
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
}}
95 kernel void pass_ro_typedef_to_wo
(ROPipeInt p
) {
96 myPipeWrite
(p); // expected-error {{passing '__private ROPipeInt' (aka '__private read_only pipe int') to parameter of incompatible type 'write_only pipe int'}}
97 // expected-note
@-
25 {{passing argument to parameter here
}}
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
}}
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
}}
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
}}