[PATCH] D34980: [OpenCL] Test on image access modifiers and image type can only be a type of a function argument.
Egor Churaev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 4 06:29:18 PDT 2017
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}}
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34980.105165.patch
Type: text/x-patch
Size: 2681 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170704/996d9dd6/attachment-0001.bin>
More information about the cfe-commits
mailing list