Skip to content

Commit f0b7493

Browse files
[SYCL][E2E] Add a test showing pre-existing swizzle-related bugs (#16352)
1 parent 40f0a6a commit f0b7493

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// RUN: %clangxx -fsycl %s -o %t_default.out
2+
// RUN: %t_default.out
3+
4+
// FIXME: Everything should compile cleanly.
5+
// RUN: %clangxx -fsycl -fsycl-device-only -DCHECK_ERRORS -fsyntax-only -Xclang -verify -Xclang -verify-ignore-unexpected=note,error %s
6+
7+
#include <sycl/vector.hpp>
8+
9+
int main() {
10+
sycl::vec<int, 4> v{1, 2, 3, 4};
11+
auto sw = v.swizzle<1, 2>();
12+
assert(sw.lo()[0] == 2);
13+
assert(sw.hi()[0] == 3);
14+
15+
// FIXME: Should be "4":
16+
assert((sw + sw).lo()[0] == 2);
17+
18+
// FIXME: The below should compile.
19+
#if CHECK_ERRORS
20+
// expected-error-re@+1 {{no template named 'swizzle' in {{.*}}}}
21+
assert(sw.swizzle<0>()[0] == 2);
22+
// expected-error-re@+1 {{no template named 'swizzle' in {{.*}}}}
23+
assert(sw.swizzle<1>()[0] == 3);
24+
25+
{
26+
// expected-error-re@+1 {{no template named 'swizzle' in {{.*}}}}
27+
auto tmp = sw.swizzle<1, 0>();
28+
assert(tmp[0] == 3);
29+
assert(tmp[1] == 2);
30+
}
31+
32+
{
33+
// expected-error-re@+1 {{no template named 'swizzle' in {{.*}}}}
34+
auto tmp = (sw + sw).swizzle<1, 0>();
35+
assert(tmp[0] == 6);
36+
assert(tmp[1] == 4);
37+
}
38+
#endif
39+
40+
return 0;
41+
}

0 commit comments

Comments
 (0)