Skip to content

Commit

Permalink
[OpenCL] Test on image access modifiers and image type can only be a …
Browse files Browse the repository at this point in the history
…type of a function argument.

Reviewers: Anastasia

Reviewed By: Anastasia

Subscribers: yaxunl, cfe-commits, bader

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

llvm-svn: 307238
  • Loading branch information
echuraev committed Jul 6, 2017
1 parent fd8777e commit ccc5e04
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions clang/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'}}
}

0 comments on commit ccc5e04

Please sign in to comment.