1 // RUN: %clang_cc1 -triple spir64 -aux-triple x86_64-unknown-linux-gnu \
2 // RUN: -fsycl -fsycl-is-device -verify -fsyntax-only %s
3
4 typedef __uint128_t BIGTY;
5
6 template <class T>
7 class Z {
8 public:
9 // expected-note@+1 {{'field' defined here}}
10 T field;
11 // expected-note@+1 2{{'field1' defined here}}
12 __int128 field1;
13 using BIGTYPE = __int128;
14 // expected-note@+1 {{'bigfield' defined here}}
15 BIGTYPE bigfield;
16 };
17
host_ok(void)18 void host_ok(void) {
19 __int128 A;
20 int B = sizeof(__int128);
21 Z<__int128> C;
22 C.field1 = A;
23 }
24
usage()25 void usage() {
26 // expected-note@+1 3{{'A' defined here}}
27 __int128 A;
28 Z<__int128> C;
29 // expected-error@+2 {{'A' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
30 // expected-error@+1 {{'field1' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
31 C.field1 = A;
32 // expected-error@+1 {{'bigfield' requires 128 bit size 'Z::BIGTYPE' (aka '__int128') type support, but device 'spir64' does not support it}}
33 C.bigfield += 1.0;
34
35 // expected-error@+1 {{'A' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
36 auto foo1 = [=]() {
37 __int128 AA;
38 // expected-note@+2 {{'BB' defined here}}
39 // expected-error@+1 {{'A' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
40 auto BB = A;
41 // expected-error@+1 {{'BB' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
42 BB += 1;
43 };
44
45 // expected-note@+1 {{called by 'usage'}}
46 foo1();
47 }
48
49 template <typename t>
foo2()50 void foo2(){};
51
52 // expected-note@+3 {{'P' defined here}}
53 // expected-error@+2 {{'P' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
54 // expected-note@+1 2{{'foo' defined here}}
foo(__int128 P)55 __int128 foo(__int128 P) { return P; }
56
foobar()57 void foobar() {
58 // expected-note@+1 {{'operator __int128' defined here}}
59 struct X { operator __int128() const; } x;
60 bool a = false;
61 // expected-error@+1 {{'operator __int128' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
62 a = x == __int128(0);
63 }
64
65 template <typename Name, typename Func>
kernel(Func kernelFunc)66 __attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
67 // expected-note@+1 6{{called by 'kernel}}
68 kernelFunc();
69 }
70
main()71 int main() {
72 // expected-note@+1 {{'CapturedToDevice' defined here}}
73 __int128 CapturedToDevice = 1;
74 host_ok();
75 kernel<class variables>([=]() {
76 decltype(CapturedToDevice) D;
77 // expected-error@+1 {{'CapturedToDevice' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
78 auto C = CapturedToDevice;
79 Z<__int128> S;
80 // expected-error@+1 {{'field1' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
81 S.field1 += 1;
82 // expected-error@+1 {{'field' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
83 S.field = 1;
84 });
85
86 kernel<class functions>([=]() {
87 // expected-note@+1 2{{called by 'operator()'}}
88 usage();
89 // expected-note@+1 {{'BBBB' defined here}}
90 BIGTY BBBB;
91 // expected-error@+3 {{'BBBB' requires 128 bit size 'BIGTY' (aka 'unsigned __int128') type support, but device 'spir64' does not support it}}
92 // expected-error@+2 2{{'foo' requires 128 bit size '__int128' type support, but device 'spir64' does not support it}}
93 // expected-note@+1 1{{called by 'operator()'}}
94 auto A = foo(BBBB);
95 // expected-note@+1 {{called by 'operator()'}}
96 foobar();
97 });
98
99 kernel<class ok>([=]() {
100 Z<__int128> S;
101 foo2<__int128>();
102 auto A = sizeof(CapturedToDevice);
103 });
104
105 return 0;
106 }
107
108 // no error expected
zoo(BIGTY h)109 BIGTY zoo(BIGTY h) {
110 h = 1;
111 return h;
112 }
113
114 namespace PR12964 {
115 struct X { operator __int128() const; } x;
116 bool a = x == __int128(0);
117 }
118
119