diff options
author | Xiuli Pan <xiulipan@outlook.com> | 2016-02-24 04:29:36 +0000 |
---|---|---|
committer | Xiuli Pan <xiulipan@outlook.com> | 2016-02-24 04:29:36 +0000 |
commit | 89307aa3e9fce213a55b64c042a001458d3ba41c (patch) | |
tree | 63eb885606d521a2e50c19cbc69cfe258e58dd75 /clang/test | |
parent | 74a1fc6f8723873bbbdf9ac62cb8a3a2cff7b8d0 (diff) | |
download | bcm5719-llvm-89307aa3e9fce213a55b64c042a001458d3ba41c.tar.gz bcm5719-llvm-89307aa3e9fce213a55b64c042a001458d3ba41c.zip |
[OpenCL] Add Sema checks for OpenCL 2.0 block
Summary:
Add Sema checks for opencl 2.0 new features: Block.
This patch is partitioned from http://reviews.llvm.org/D16047
Reviewers: Anastasia
Subscribers: pekka.jaaskelainen, cfe-commits
Differential Revision: http://reviews.llvm.org/D17436
llvm-svn: 261719
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/SemaOpenCL/invalid-block.cl | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/SemaOpenCL/invalid-block.cl b/clang/test/SemaOpenCL/invalid-block.cl new file mode 100644 index 00000000000..c3989a28c83 --- /dev/null +++ b/clang/test/SemaOpenCL/invalid-block.cl @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -verify -fblocks -cl-std=CL2.0 %s + +int (^BlkVariadic)(int, ...) = ^int(int I, ...) { // expected-error {{invalid block prototype, variadic arguments are not allowed in OpenCL}} + return 0; +}; + +typedef int (^BlkInt)(int); +void f1(int i) { + BlkInt B1 = ^int(int I) {return 1;}; + BlkInt B2 = ^int(int I) {return 2;}; + BlkInt Arr[] = {B1, B2}; // expected-error {{array of 'BlkInt' (aka 'int (^)(int)') type is invalid in OpenCL}} + int tmp = i ? B1(i) // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}} + : B2(i); // expected-error {{block type cannot be used as expression in ternary expression in OpenCL}} +} + +void f2(BlkInt *BlockPtr) { + BlkInt B = ^int(int I) {return 1;}; + BlkInt *P = &B; // expected-error {{invalid argument type 'BlkInt' (aka 'int (^)(int)') to unary expression}} + B = *BlockPtr; // expected-error {{dereferencing pointer of type '__generic BlkInt *' (aka 'int (^__generic *)(int)') is not allowed in OpenCL}} +} |