From: Egor Churaev Date: Thu, 6 Jul 2017 07:06:11 +0000 (+0000) Subject: [OpenCL] Test on image access modifiers and image type can only be a type of a functi... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f7e486629c1484d91197739790471f291d36867c;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307238 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/SemaOpenCL/images.cl b/test/SemaOpenCL/images.cl index f963de4e13..9d6092c8c9 100644 --- a/test/SemaOpenCL/images.cl +++ b/test/SemaOpenCL/images.cl @@ -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'}} +}