1 // RUN: %clang_cc1 -triple spir64 -fsycl -fsycl-is-device -verify -fsyntax-only %s
2 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsycl -fsycl-is-device -fsyntax-only %s
3 
4 typedef __float128 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   __float128 field1;
13   using BIGTYPE = __float128;
14   // expected-note@+1 {{'bigfield' defined here}}
15   BIGTYPE bigfield;
16 };
17 
host_ok(void)18 void host_ok(void) {
19   __float128 A;
20   int B = sizeof(__float128);
21   Z<__float128> C;
22   C.field1 = A;
23 }
24 
usage()25 void usage() {
26   // expected-note@+1 3{{'A' defined here}}
27   __float128 A;
28   Z<__float128> C;
29   // expected-error@+2 {{'A' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
30   // expected-error@+1 {{'field1' requires 128 bit size '__float128' 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 '__float128') type support, but device 'spir64' does not support it}}
33   C.bigfield += 1.0;
34 
35   // expected-error@+1 {{'A' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
36   auto foo1 = [=]() {
37     __float128 AA;
38     // expected-note@+2 {{'BB' defined here}}
39     // expected-error@+1 {{'A' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
40     auto BB = A;
41     // expected-error@+1 {{'BB' requires 128 bit size '__float128' 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 '__float128' type support, but device 'spir64' does not support it}}
54 // expected-note@+1 2{{'foo' defined here}}
foo(__float128 P)55 __float128 foo(__float128 P) { return P; }
56 
57 template <typename Name, typename Func>
kernel(Func kernelFunc)58 __attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
59   // expected-note@+1 5{{called by 'kernel}}
60   kernelFunc();
61 }
62 
main()63 int main() {
64   // expected-note@+1 {{'CapturedToDevice' defined here}}
65   __float128 CapturedToDevice = 1;
66   host_ok();
67   kernel<class variables>([=]() {
68     decltype(CapturedToDevice) D;
69     // expected-error@+1 {{'CapturedToDevice' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
70     auto C = CapturedToDevice;
71     Z<__float128> S;
72     // expected-error@+1 {{'field1' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
73     S.field1 += 1;
74     // expected-error@+1 {{'field' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
75     S.field = 1;
76   });
77 
78   kernel<class functions>([=]() {
79     // expected-note@+1 2{{called by 'operator()'}}
80     usage();
81     // expected-note@+1 {{'BBBB' defined here}}
82     BIGTY BBBB;
83     // expected-note@+3 {{called by 'operator()'}}
84     // expected-error@+2 2{{'foo' requires 128 bit size '__float128' type support, but device 'spir64' does not support it}}
85     // expected-error@+1 {{'BBBB' requires 128 bit size 'BIGTY' (aka '__float128') type support, but device 'spir64' does not support it}}
86     auto A = foo(BBBB);
87   });
88 
89   kernel<class ok>([=]() {
90     Z<__float128> S;
91     foo2<__float128>();
92     auto A = sizeof(CapturedToDevice);
93   });
94 
95   return 0;
96 }
97