[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / x86_64-no-x87.cpp
blobb47e69e4b350cc0140d6393229ec450d4ea64cf5
1 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -target-feature -x87
2 // RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -DNOERROR
4 #ifdef NOERROR
5 // expected-no-diagnostics
6 #endif
8 typedef long double long_double;
10 // Declaration is fine, unless it is called or defined.
11 double decl(long_double x, long_double y);
13 template <typename T>
14 T decl_ld_del(T);
16 // No code is generated for deleted functions
17 long_double decl_ld_del(long_double) = delete;
18 double decl_ld_del(double) = delete;
19 float decl_ld_del(float) = delete;
21 #ifndef NOERROR
22 // expected-error@+4{{'def' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
23 // expected-note@+3{{'def' defined here}}
24 // expected-note@+2{{'x' defined here}}
25 #endif
26 int def(long_double x) {
27 #ifndef NOERROR
28 // expected-error@+2{{'x' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
29 #endif
30 return (int)x;
33 #ifndef NOERROR
34 // expected-note@+3{{'ld_args' defined here}}
35 // expected-note@+2{{'ld_args' defined here}}
36 #endif
37 int ld_args(long_double x, long_double y);
39 int call1(float x, float y) {
40 #ifndef NOERROR
41 // expected-error@+2 2{{'ld_args' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
42 #endif
43 return ld_args(x, y);
46 #ifndef NOERROR
47 // expected-note@+2{{'ld_ret' defined here}}
48 #endif
49 long_double ld_ret(double x, double y);
51 int call2(float x, float y) {
52 #ifndef NOERROR
53 // expected-error@+2{{'ld_ret' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
54 #endif
55 return (int)ld_ret(x, y);
58 int binop(double x, double y) {
59 #ifndef NOERROR
60 // expected-error@+2 2{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
61 #endif
62 double z = (long_double)x * (long_double)y;
63 return (int)z;
66 void assign1(long_double *ret, double x) {
67 #ifndef NOERROR
68 // expected-error@+2{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
69 #endif
70 *ret = x;
73 struct st_long_double1 {
74 #ifndef NOERROR
75 // expected-note@+2{{'ld' defined here}}
76 #endif
77 long_double ld;
80 struct st_long_double2 {
81 #ifndef NOERROR
82 // expected-note@+2{{'ld' defined here}}
83 #endif
84 long_double ld;
87 struct st_long_double3 {
88 #ifndef NOERROR
89 // expected-note@+2{{'ld' defined here}}
90 #endif
91 long_double ld;
94 void assign2() {
95 struct st_long_double1 st;
96 #ifndef NOERROR
97 // expected-error@+3{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
98 // expected-error@+2{{'ld' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
99 #endif
100 st.ld = 0.42;
103 void assign3() {
104 struct st_long_double2 st;
105 #ifndef NOERROR
106 // expected-error@+3{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
107 // expected-error@+2{{'ld' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
108 #endif
109 st.ld = 42;
112 void assign4(double d) {
113 struct st_long_double3 st;
114 #ifndef NOERROR
115 // expected-error@+3{{expression requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
116 // expected-error@+2{{'ld' requires 'long_double' (aka 'long double') type support, but target 'x86_64-unknown-linux-gnu' does not support it}}
117 #endif
118 st.ld = d;
121 void assign5() {
122 // unused variable declaration is fine
123 long_double ld = 0.42;
126 // Double and Float return type on x86_64 do not use x87 registers
127 double d_ret1(float x) {
128 return 0.0;
131 double d_ret2(float x);
133 int d_ret3(float x) {
134 return (int)d_ret2(x);
137 float f_ret1(float x) {
138 return 0.0f;
141 float f_ret2(float x);
143 int f_ret3(float x) {
144 return (int)f_ret2(x);