xref: /llvm-project/clang/test/SemaOpenCL/ext_vectors.cl (revision 0aab344104034e6191114a74f0d9eb5129bf550d)
1// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.1
2// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
3// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL3.0
4// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++1.0
5// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=clc++2021
6
7typedef float float4 __attribute__((ext_vector_type(4)));
8typedef __attribute__((ext_vector_type(8))) bool BoolVector; // expected-error {{invalid vector element type 'bool'}}
9
10void test_ext_vector_accessors(float4 V) {
11  V = V.wzyx;
12
13  V = V.abgr;
14#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || (defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
15  // expected-warning@-2 {{vector component name 'a' is a feature from OpenCL version 3.0 onwards}}
16#endif
17
18  V = V.xyzr;
19  // expected-error@-1 {{illegal vector component name 'r'}}
20#if ((defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ < 300) || (defined(__OPENCL_CPP_VERSION__) && __OPENCL_CPP_VERSION__ < 202100))
21  // expected-warning@-3 {{vector component name 'r' is a feature from OpenCL version 3.0 onwards}}
22#endif
23}
24