echuraev created this revision.
Herald added a subscriber: yaxunl.

https://reviews.llvm.org/D34980

Files:
  test/SemaOpenCL/images.cl


Index: test/SemaOpenCL/images.cl
===================================================================
--- test/SemaOpenCL/images.cl
+++ test/SemaOpenCL/images.cl
@@ -1,9 +1,43 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
 
-void img2d_ro(__read_only image2d_t img) {} // expected-note{{passing argument 
to parameter 'img' here}} expected-note{{passing argument to parameter 'img' 
here}}
+void img2d_ro(__read_only image2d_t img) {} // expected-note 2{{passing 
argument to parameter 'img' here}}
 
 void imgage_access_test(image2d_t img2dro, write_only image2d_t img2dwo, 
image3d_t img3dro) {
   img2d_ro(img2dro);
   img2d_ro(img2dwo); // expected-error{{passing '__write_only image2d_t' to 
parameter of incompatible type '__read_only image2d_t'}}
   img2d_ro(img3dro); // expected-error{{passing '__read_only image3d_t' to 
parameter of incompatible type '__read_only image2d_t'}}
 }
+
+void myWrite(write_only image2d_t); // expected-note 2{{passing argument to 
parameter here}}
+void myRead (read_only image2d_t); // expected-note 2{{passing argument to 
parameter here}}
+void myReadWrite (read_write image2d_t);
+void myIndifferent (image2d_t); // expected-note 2{{passing argument to 
parameter here}}
+
+
+kernel void k1 (read_only image2d_t img) {
+  myWrite(img); // expected-error {{passing '__read_only image2d_t' to 
parameter of incompatible type '__write_only image2d_t'}}
+}
+
+kernel void k2 (write_only image2d_t img) {
+  myRead(img); // expected-error {{passing '__write_only image2d_t' to 
parameter of incompatible type '__read_only image2d_t'}}
+}
+
+// Should be all OK.
+kernel void k3 (read_write image2d_t img) {
+  myRead(img);  // expected-error {{passing '__read_write image2d_t' to 
parameter of incompatible type '__read_only image2d_t'}}
+  myWrite(img); // expected-error {{passing '__read_write image2d_t' to 
parameter of incompatible type '__write_only image2d_t'}}
+  myReadWrite(img); //read_write = read_write
+}
+
+// Legal to path everything to an 'indifferent' function.
+kernel void k4(read_write image2d_t i1, read_only image2d_t i2,
+               write_only image2d_t i3) {
+  myIndifferent(i1); // expected-error {{passing '__read_write image2d_t' to 
parameter of incompatible type '__read_only image2d_t'}}
+  myIndifferent(i2);
+  myIndifferent(i3); // expected-error {{passing '__write_only image2d_t' to 
parameter of incompatible type '__read_only image2d_t'}}
+}
+
+kernel void k5(read_only image2d_t srcimg)
+{
+  read_only image2d_t tmp = srcimg; // expected-error {{type '__read_only 
image2d_t' can only be used as a function parameter in OpenCL}}
+}


Index: test/SemaOpenCL/images.cl
===================================================================
--- test/SemaOpenCL/images.cl
+++ test/SemaOpenCL/images.cl
@@ -1,9 +1,43 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
 
-void img2d_ro(__read_only image2d_t img) {} // expected-note{{passing argument to parameter 'img' here}} expected-note{{passing argument to parameter 'img' here}}
+void img2d_ro(__read_only image2d_t img) {} // expected-note 2{{passing argument to parameter 'img' here}}
 
 void imgage_access_test(image2d_t img2dro, write_only image2d_t img2dwo, image3d_t img3dro) {
   img2d_ro(img2dro);
   img2d_ro(img2dwo); // expected-error{{passing '__write_only image2d_t' to parameter of incompatible type '__read_only image2d_t'}}
   img2d_ro(img3dro); // expected-error{{passing '__read_only image3d_t' to parameter of incompatible type '__read_only image2d_t'}}
 }
+
+void myWrite(write_only image2d_t); // expected-note 2{{passing argument to parameter here}}
+void myRead (read_only image2d_t); // expected-note 2{{passing argument to parameter here}}
+void myReadWrite (read_write image2d_t);
+void myIndifferent (image2d_t); // expected-note 2{{passing argument to parameter here}}
+
+
+kernel void k1 (read_only image2d_t img) {
+  myWrite(img); // expected-error {{passing '__read_only image2d_t' to parameter of incompatible type '__write_only image2d_t'}}
+}
+
+kernel void k2 (write_only image2d_t img) {
+  myRead(img); // expected-error {{passing '__write_only image2d_t' to parameter of incompatible type '__read_only image2d_t'}}
+}
+
+// Should be all OK.
+kernel void k3 (read_write image2d_t img) {
+  myRead(img);  // expected-error {{passing '__read_write image2d_t' to parameter of incompatible type '__read_only image2d_t'}}
+  myWrite(img); // expected-error {{passing '__read_write image2d_t' to parameter of incompatible type '__write_only image2d_t'}}
+  myReadWrite(img); //read_write = read_write
+}
+
+// Legal to path everything to an 'indifferent' function.
+kernel void k4(read_write image2d_t i1, read_only image2d_t i2,
+               write_only image2d_t i3) {
+  myIndifferent(i1); // expected-error {{passing '__read_write image2d_t' to parameter of incompatible type '__read_only image2d_t'}}
+  myIndifferent(i2);
+  myIndifferent(i3); // expected-error {{passing '__write_only image2d_t' to parameter of incompatible type '__read_only image2d_t'}}
+}
+
+kernel void k5(read_only image2d_t srcimg)
+{
+  read_only image2d_t tmp = srcimg; // expected-error {{type '__read_only image2d_t' can only be used as a function parameter in OpenCL}}
+}
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to