summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaOpenCL/arithmetic-conversions.cl
diff options
context:
space:
mode:
authorEgor Churaev <egor.churaev@intel.com>2017-05-26 13:30:26 +0000
committerEgor Churaev <egor.churaev@intel.com>2017-05-26 13:30:26 +0000
commit1adf2652873db196875277134e0502fad57f4543 (patch)
treedd410dfb9d3b72de513d2e742305a8afbde2d9b1 /clang/test/SemaOpenCL/arithmetic-conversions.cl
parentfdb264e2635c6b02e7543f6a4bac675e62275696 (diff)
downloadbcm5719-llvm-1adf2652873db196875277134e0502fad57f4543.tar.gz
bcm5719-llvm-1adf2652873db196875277134e0502fad57f4543.zip
[OpenCL] An error shall occur if any scalar operand has greater rank than the type of the vector element
Reviewers: Anastasia Reviewed By: Anastasia Subscribers: cfe-commits, bader, yaxunl Differential Revision: https://reviews.llvm.org/D33353 llvm-svn: 303986
Diffstat (limited to 'clang/test/SemaOpenCL/arithmetic-conversions.cl')
-rw-r--r--clang/test/SemaOpenCL/arithmetic-conversions.cl23
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/test/SemaOpenCL/arithmetic-conversions.cl b/clang/test/SemaOpenCL/arithmetic-conversions.cl
new file mode 100644
index 00000000000..64c35e84b5a
--- /dev/null
+++ b/clang/test/SemaOpenCL/arithmetic-conversions.cl
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2
+
+typedef float float2 __attribute__((ext_vector_type(2)));
+typedef long long2 __attribute__((ext_vector_type(2)));
+typedef int int2 __attribute__((ext_vector_type(2)));
+
+kernel void foo1(float2 in, global float2 *out) { *out = in + 0.5;} // expected-error {{scalar operand type has greater rank than the type of the vector element. ('float2' (vector of 2 'float' values) and 'double')}}
+
+kernel void foo2(float2 in, global float2 *out) { *out = 0.5 + in;} // expected-error {{scalar operand type has greater rank than the type of the vector element. ('double' and 'float2' (vector of 2 'float' values))}}
+
+kernel void foo3(float2 in, global float2 *out) { *out = 0.5f + in;}
+
+kernel void foo4(long2 in, global long2 *out) { *out = 5 + in;}
+
+kernel void foo5(float2 in, global float2 *out) {
+ float* f;
+ *out = f + in; // expected-error{{cannot convert between vector and non-scalar values ('float *' and 'float2' (vector of 2 'float' values))}}
+}
+
+kernel void foo6(int2 in, global int2 *out) {
+ int* f;
+ *out = f + in; // expected-error{{cannot convert between vector and non-scalar values ('int *' and 'int2' (vector of 2 'int' values))}}
+}
OpenPOWER on IntegriCloud