r307238 - [OpenCL] Test on image access modifiers and image type can only be a type of a function argument.

Egor Churaev via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 6 00:06:11 PDT 2017


Author: echuraev
Date: Thu Jul  6 00:06:11 2017
New Revision: 307238

URL: http://llvm.org/viewvc/llvm-project?rev=307238&view=rev
Log:
[OpenCL] Test on image access modifiers and image type can only be a type of a function argument.

Reviewers: Anastasia

Reviewed By: Anastasia

Subscribers: yaxunl, cfe-commits, bader

Differential Revision: https://reviews.llvm.org/D34980

Modified:
    cfe/trunk/test/SemaOpenCL/images.cl

Modified: cfe/trunk/test/SemaOpenCL/images.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/images.cl?rev=307238&r1=307237&r2=307238&view=diff
==============================================================================
--- cfe/trunk/test/SemaOpenCL/images.cl (original)
+++ cfe/trunk/test/SemaOpenCL/images.cl Thu Jul  6 00:06:11 2017
@@ -1,9 +1,32 @@
-// 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); // expected-note 3{{passing argument to parameter here}}
+void img2d_wo(write_only image2d_t); // expected-note 2{{passing argument to parameter here}}
+void img2d_rw(read_write image2d_t); // expected-note 2{{passing argument to parameter here}}
+void img2d_default(image2d_t); // expected-note 2{{passing argument to parameter 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'}}
+void imgage_access_test(image2d_t img2dro, image3d_t img3dro) {
+  img2d_ro(img2dro); // read_only = read_only
   img2d_ro(img3dro); // expected-error{{passing '__read_only image3d_t' to parameter of incompatible type '__read_only image2d_t'}}
 }
+
+kernel void read_only_access_test(read_only image2d_t img) {
+  img2d_ro(img); // read_only = read_only
+  img2d_wo(img); // expected-error {{passing '__read_only image2d_t' to parameter of incompatible type '__write_only image2d_t'}}
+  img2d_rw(img); // expected-error {{passing '__read_only image2d_t' to parameter of incompatible type '__read_write image2d_t'}}
+  img2d_default(img); // read_only = read_only
+}
+
+kernel void write_only_access_test(write_only image2d_t img) {
+  img2d_ro(img); // expected-error {{passing '__write_only image2d_t' to parameter of incompatible type '__read_only image2d_t'}}
+  img2d_wo(img); // write_only = write_only
+  img2d_rw(img); // expected-error {{passing '__write_only image2d_t' to parameter of incompatible type '__read_write image2d_t'}}
+  img2d_default(img); // expected-error {{passing '__write_only image2d_t' to parameter of incompatible type '__read_only image2d_t'}}
+}
+
+kernel void read_write_access_test(read_write image2d_t img) {
+  img2d_ro(img);  // expected-error {{passing '__read_write image2d_t' to parameter of incompatible type '__read_only image2d_t'}}
+  img2d_wo(img); // expected-error {{passing '__read_write image2d_t' to parameter of incompatible type '__write_only image2d_t'}}
+  img2d_rw(img); //read_write = read_write
+  img2d_default(img); // expected-error {{passing '__read_write image2d_t' to parameter of incompatible type '__read_only image2d_t'}}
+}




More information about the cfe-commits mailing list