Home | History | Annotate | Download | only in SemaOpenCL
      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-error{{multiple access qualifiers}}
     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 '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