diff options
| author | Tobias Grosser <grosser@fim.uni-passau.de> | 2011-09-22 13:03:14 +0000 |
|---|---|---|
| committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2011-09-22 13:03:14 +0000 |
| commit | 766bcc27dc79b46ea285e3c7f493a69ab5c0115b (patch) | |
| tree | d3b9bbfbeb6722cb210ccdd49d5bdf048f954d3c /clang/test/SemaOpenCL | |
| parent | 6d1872b77ad67479f002c1e11b9ed7851d03a275 (diff) | |
| download | bcm5719-llvm-766bcc27dc79b46ea285e3c7f493a69ab5c0115b.tar.gz bcm5719-llvm-766bcc27dc79b46ea285e3c7f493a69ab5c0115b.zip | |
In OpenCL, conversions between different vector types are disallowed
OpenCL 6.2.1 says: "Implicit conversions between built-in vector data types are
disallowed." OpenCL 6.2.2 says: "Explicit casts between vector types are not
legal." For example:
uint4 u = (uint4)(1);
int4 i = u; // invalid implicit conversion
int4 e = (int4)u; // invalid explicit conversion
Fixes PR10967. Submitted by: Anton Lokhmotov <Anton.lokhmotov@gmail.com>
llvm-svn: 140300
Diffstat (limited to 'clang/test/SemaOpenCL')
| -rw-r--r-- | clang/test/SemaOpenCL/vector_conv_invalid.cl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/test/SemaOpenCL/vector_conv_invalid.cl b/clang/test/SemaOpenCL/vector_conv_invalid.cl new file mode 100644 index 00000000000..e6ef5a492f8 --- /dev/null +++ b/clang/test/SemaOpenCL/vector_conv_invalid.cl @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -verify %s + +typedef unsigned int uint4 __attribute((ext_vector_type(4))); +typedef int int4 __attribute((ext_vector_type(4))); +typedef int int3 __attribute((ext_vector_type(3))); +typedef unsigned uint3 __attribute((ext_vector_type(3))); + +void vector_conv_invalid() { + uint4 u = (uint4)(1); + int4 i = u; // expected-error{{initializing 'int4' with an expression of incompatible type 'uint4'}} + int4 e = (int4)u; // expected-error{{invalid conversion between ext-vector type 'int4' and 'uint4'}} + + uint3 u4 = (uint3)u; // expected-error{{invalid conversion between ext-vector type 'uint3' and 'uint4'}} +} |

