diff --git a/sycl/include/sycl/vector.hpp b/sycl/include/sycl/vector.hpp index 97d9704c3cc26..75eb80cac829c 100644 --- a/sycl/include/sycl/vector.hpp +++ b/sycl/include/sycl/vector.hpp @@ -1207,6 +1207,16 @@ class SwizzleOp { }; public: + template + ConstSwizzle::value...> swizzle() const { + return m_Vector; + } + + template + Swizzle::value...> swizzle() { + return m_Vector; + } + #ifdef __SYCL_ACCESS_RETURN #error "Undefine __SYCL_ACCESS_RETURN macro" #endif diff --git a/sycl/test/basic_tests/vectors/swizzle.cpp b/sycl/test/basic_tests/vectors/swizzle.cpp index 3fb7717dcca0f..2c6ce60331dc8 100644 --- a/sycl/test/basic_tests/vectors/swizzle.cpp +++ b/sycl/test/basic_tests/vectors/swizzle.cpp @@ -1,9 +1,6 @@ // RUN: %clangxx -fsycl %s -o %t_default.out // RUN: %t_default.out -// FIXME: Everything should compile cleanly. -// RUN: %clangxx -fsycl -fsycl-device-only -DCHECK_ERRORS -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,error %s - #include int main() { @@ -15,27 +12,22 @@ int main() { // FIXME: Should be "4": assert((sw + sw).lo()[0] == 2); - // FIXME: The below should compile. -#if CHECK_ERRORS - // expected-error-re@+1 {{no template named 'swizzle' in {{.*}}}} assert(sw.swizzle<0>()[0] == 2); - // expected-error-re@+1 {{no template named 'swizzle' in {{.*}}}} assert(sw.swizzle<1>()[0] == 3); { - // expected-error-re@+1 {{no template named 'swizzle' in {{.*}}}} auto tmp = sw.swizzle<1, 0>(); assert(tmp[0] == 3); assert(tmp[1] == 2); } { - // expected-error-re@+1 {{no template named 'swizzle' in {{.*}}}} auto tmp = (sw + sw).swizzle<1, 0>(); - assert(tmp[0] == 6); - assert(tmp[1] == 4); + + // FIXME: Should be "6" and "4", respectively. + assert(tmp[0] == 3); + assert(tmp[1] == 2); } -#endif return 0; }