[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaSYCL / float128.cpp
blobb1a022216aafff95ea22859fccd8f50044a6c21c
1 // RUN: %clang_cc1 -triple spir64 -fsycl-is-device -verify -fsyntax-only %s
2 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fsycl-is-device -fsyntax-only %s
4 typedef __float128 BIGTY;
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;
18 void host_ok(void) {
19 __float128 A;
20 int B = sizeof(__float128);
21 Z<__float128> C;
22 C.field1 = A;
25 long double ld_func(long double arg);
27 void usage() {
28 // expected-note@+1 3{{'A' defined here}}
29 __float128 A;
30 Z<__float128> C;
31 // expected-error@+3 2{{expression requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
32 // expected-error@+2 {{'A' requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
33 // expected-error@+1 {{'field1' requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
34 C.field1 = A;
35 // expected-error@+2 {{expression requires 128 bit size 'BIGTYPE' (aka '__float128') type support, but target 'spir64' does not support it}}
36 // expected-error@+1 {{'bigfield' requires 128 bit size 'BIGTYPE' (aka '__float128') type support, but target 'spir64' does not support it}}
37 C.bigfield += 1.0;
39 // expected-error@+1 {{'A' requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
40 auto foo1 = [=]() {
41 __float128 AA;
42 // expected-note@+2 {{'BB' defined here}}
43 // expected-error@+1 {{'A' requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
44 auto BB = A;
45 // expected-error@+2 {{expression requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
46 // expected-error@+1 {{'BB' requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
47 BB += 1;
49 float F1 = 0.1f;
50 float F2 = 0.1f;
51 // expected-error@+1 3{{expression requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
52 float F3 = ((__float128)F1 * (__float128)F2) / 2.0f;
54 // assume that long double is supported
55 float F4 = ld_func(F3);
58 // expected-note@+1 {{called by 'usage'}}
59 foo1();
62 template <typename t>
63 void foo2(){};
65 // expected-note@+3 {{'P' defined here}}
66 // expected-error@+2 {{'P' requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
67 // expected-note@+1 2{{'foo' defined here}}
68 __float128 foo(__float128 P) { return P; }
70 template <typename Name, typename Func>
71 __attribute__((sycl_kernel)) void kernel(Func kernelFunc) {
72 // expected-note@+1 5{{called by 'kernel}}
73 kernelFunc();
76 int main() {
77 // expected-note@+1 {{'CapturedToDevice' defined here}}
78 __float128 CapturedToDevice = 1;
79 host_ok();
80 kernel<class variables>([=]() {
81 decltype(CapturedToDevice) D;
82 // expected-error@+1 {{'CapturedToDevice' requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
83 auto C = CapturedToDevice;
84 Z<__float128> S;
85 // expected-error@+2 {{expression requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
86 // expected-error@+1 {{'field1' requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
87 S.field1 += 1;
88 // expected-error@+2 {{expression requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
89 // expected-error@+1 {{'field' requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
90 S.field = 1;
91 });
93 kernel<class functions>([=]() {
94 // expected-note@+1 2{{called by 'operator()'}}
95 usage();
96 // expected-note@+1 {{'BBBB' defined here}}
97 BIGTY BBBB;
98 // expected-note@+3 {{called by 'operator()'}}
99 // expected-error@+2 {{'BBBB' requires 128 bit size 'BIGTY' (aka '__float128') type support, but target 'spir64' does not support it}}
100 // expected-error@+1 2{{'foo' requires 128 bit size '__float128' type support, but target 'spir64' does not support it}}
101 auto A = foo(BBBB);
104 kernel<class ok>([=]() {
105 Z<__float128> S;
106 foo2<__float128>();
107 auto A = sizeof(CapturedToDevice);
110 return 0;