Debian Codegraph @

gcc/testsuite/g++.dg/cpp23/ext-floating12.C

raw
1 // P1467R9 - Extended floating-point types and standard names.
2 // { dg-do compile { target { c++23 && { i?86-*-linux* x86_64-*-linux* } } } }
3 // { dg-options "" }
4 // { dg-add-options float16 }
5 // { dg-add-options bfloat16 }
6 // { dg-skip-if "requires hosted libstdc++ for complex" { ! hostedlib } }
7
8 #include <complex>
9 #include <stdfloat>
10
11 #if !defined(__STDCPP_FLOAT32_T__) \
12 || !defined(__STDCPP_FLOAT64_T__) || !defined(__STDCPP_FLOAT128_T__) \
13 || __FLT_MAX_EXP__ != __FLT32_MAX_EXP__ || __FLT_MANT_DIG__ != __FLT32_MANT_DIG__ \
14 || __DBL_MAX_EXP__ != __FLT64_MAX_EXP__ || __DBL_MANT_DIG__ != __FLT64_MANT_DIG__ \
15 || __LDBL_MAX_EXP__ != __FLT128_MAX_EXP__ || __LDBL_MANT_DIG__ >= __FLT128_MANT_DIG__ \
16 || !defined(__SIZEOF_FLOAT128__)
17 #error Unexpected set of floating point types
18 #endif
19
20 using namespace std;
21
22 int
23 main()
24 {
25 complex<float> a01(complex<float>(1.0f, 2.0f));
26 complex<float> a02 = complex<float>(1.0f, 2.0f);
27 complex<float> a03(complex<double>(1.0, 2.0));
28 complex<float> a04 = complex<double>(1.0, 2.0); // { dg-error "conversion from 'complex<double>' to non-scalar type 'complex<float>' requested" }
29 complex<float> a05(complex<long double>(1.0L, 2.0L));
30 complex<float> a06 = complex<long double>(1.0L, 2.0L); // { dg-error "conversion from 'complex<long double>' to non-scalar type 'complex<float>' requested" }
31 complex<float> a07(complex<float32_t>(1.0f32, 2.0f32));
32 complex<float> a08 = complex<float32_t>(1.0f32, 2.0f32);
33 complex<float> a09(complex<float64_t>(1.0f64, 2.0f64));
34 complex<float> a10 = complex<float64_t>(1.0f64, 2.0f64); // { dg-error "conversion from 'complex<_Float64>' to non-scalar type 'complex<float>' requested" }
35 complex<float> a11(complex<float128_t>(1.0f128, 2.0f128));
36 complex<float> a12 = complex<float128_t>(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex<float>' requested" }
37 #ifdef __STDCPP_FLOAT16_T__
38 complex<float> a13(complex<float16_t>(1.0f16, 2.0f16));
39 complex<float> a14 = complex<float16_t>(1.0f16, 2.0f16);
40 #endif
41 #ifdef __STDCPP_BFLOAT16_T__
42 complex<float> a15(complex<bfloat16_t>(1.0bf16, 2.0bf16));
43 complex<float> a16 = complex<bfloat16_t>(1.0bf16, 2.0bf16);
44 #endif
45 complex<double> b01(complex<float>(1.0f, 2.0f));
46 complex<double> b02 = complex<float>(1.0f, 2.0f);
47 complex<double> b03(complex<double>(1.0, 2.0));
48 complex<double> b04 = complex<double>(1.0, 2.0);
49 complex<double> b05(complex<long double>(1.0L, 2.0L));
50 complex<double> b06 = complex<long double>(1.0L, 2.0L); // { dg-error "conversion from 'complex<long double>' to non-scalar type 'complex<double>' requested" }
51 complex<double> b07(complex<float32_t>(1.0f32, 2.0f32));
52 complex<double> b08 = complex<float32_t>(1.0f32, 2.0f32);
53 complex<double> b09(complex<float64_t>(1.0f64, 2.0f64));
54 complex<double> b10 = complex<float64_t>(1.0f64, 2.0f64);
55 complex<double> b11(complex<float128_t>(1.0f128, 2.0f128));
56 complex<double> b12 = complex<float128_t>(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex<double>' requested" }
57 #ifdef __STDCPP_FLOAT16_T__
58 complex<double> b13(complex<float16_t>(1.0f16, 2.0f16));
59 complex<double> b14 = complex<float16_t>(1.0f16, 2.0f16);
60 #endif
61 #ifdef __STDCPP_BFLOAT16_T__
62 complex<double> b15(complex<bfloat16_t>(1.0bf16, 2.0bf16));
63 complex<double> b16 = complex<bfloat16_t>(1.0bf16, 2.0bf16);
64 #endif
65 complex<long double> c01(complex<float>(1.0f, 2.0f));
66 complex<long double> c02 = complex<float>(1.0f, 2.0f);
67 complex<long double> c03(complex<double>(1.0, 2.0));
68 complex<long double> c04 = complex<double>(1.0, 2.0);
69 complex<long double> c05(complex<long double>(1.0L, 2.0L));
70 complex<long double> c06 = complex<long double>(1.0L, 2.0L);
71 complex<long double> c07(complex<float32_t>(1.0f32, 2.0f32));
72 complex<long double> c08 = complex<float32_t>(1.0f32, 2.0f32);
73 complex<long double> c09(complex<float64_t>(1.0f64, 2.0f64));
74 complex<long double> c10 = complex<float64_t>(1.0f64, 2.0f64);
75 complex<long double> c11(complex<float128_t>(1.0f128, 2.0f128));
76 complex<long double> c12 = complex<float128_t>(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex<long double>' requested" }
77 #ifdef __STDCPP_FLOAT16_T__
78 complex<long double> c13(complex<float16_t>(1.0f16, 2.0f16));
79 complex<long double> c14 = complex<float16_t>(1.0f16, 2.0f16);
80 #endif
81 #ifdef __STDCPP_BFLOAT16_T__
82 complex<long double> c15(complex<bfloat16_t>(1.0bf16, 2.0bf16));
83 complex<long double> c16 = complex<bfloat16_t>(1.0bf16, 2.0bf16);
84 #endif
85 complex<float32_t> d01(complex<float>(1.0f, 2.0f));
86 complex<float32_t> d02 = complex<float>(1.0f, 2.0f);
87 complex<float32_t> d03(complex<double>(1.0, 2.0));
88 complex<float32_t> d04 = complex<double>(1.0, 2.0); // { dg-error "conversion from 'complex<double>' to non-scalar type 'complex<_Float32>' requested" }
89 complex<float32_t> d05(complex<long double>(1.0L, 2.0L));
90 complex<float32_t> d06 = complex<long double>(1.0L, 2.0L); // { dg-error "conversion from 'complex<long double>' to non-scalar type 'complex<_Float32>' requested" }
91 complex<float32_t> d07(complex<float32_t>(1.0f32, 2.0f32));
92 complex<float32_t> d08 = complex<float32_t>(1.0f32, 2.0f32);
93 complex<float32_t> d09(complex<float64_t>(1.0f64, 2.0f64));
94 complex<float32_t> d10 = complex<float64_t>(1.0f64, 2.0f64); // { dg-error "conversion from 'complex<_Float64>' to non-scalar type 'complex<_Float32>' requested" }
95 complex<float32_t> d11(complex<float128_t>(1.0f128, 2.0f128));
96 complex<float32_t> d12 = complex<float128_t>(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex<_Float32>' requested" }
97 #ifdef __STDCPP_FLOAT16_T__
98 complex<float32_t> d13(complex<float16_t>(1.0f16, 2.0f16));
99 complex<float32_t> d14 = complex<float16_t>(1.0f16, 2.0f16);
100 #endif
101 #ifdef __STDCPP_BFLOAT16_T__
102 complex<float32_t> d15(complex<bfloat16_t>(1.0bf16, 2.0bf16));
103 complex<float32_t> d16 = complex<bfloat16_t>(1.0bf16, 2.0bf16);
104 #endif
105 complex<float64_t> e01(complex<float>(1.0f, 2.0f));
106 complex<float64_t> e02 = complex<float>(1.0f, 2.0f);
107 complex<float64_t> e03(complex<double>(1.0, 2.0));
108 complex<float64_t> e04 = complex<double>(1.0, 2.0);
109 complex<float64_t> e05(complex<long double>(1.0L, 2.0L));
110 complex<float64_t> e06 = complex<long double>(1.0L, 2.0L); // { dg-error "conversion from 'complex<long double>' to non-scalar type 'complex<_Float64>' requested" }
111 complex<float64_t> e07(complex<float32_t>(1.0f32, 2.0f32));
112 complex<float64_t> e08 = complex<float32_t>(1.0f32, 2.0f32);
113 complex<float64_t> e09(complex<float64_t>(1.0f64, 2.0f64));
114 complex<float64_t> e10 = complex<float64_t>(1.0f64, 2.0f64);
115 complex<float64_t> e11(complex<float128_t>(1.0f128, 2.0f128));
116 complex<float64_t> e12 = complex<float128_t>(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex<_Float64>' requested" }
117 #ifdef __STDCPP_FLOAT16_T__
118 complex<float64_t> e13(complex<float16_t>(1.0f16, 2.0f16));
119 complex<float64_t> e14 = complex<float16_t>(1.0f16, 2.0f16);
120 #endif
121 #ifdef __STDCPP_BFLOAT16_T__
122 complex<float64_t> e15(complex<bfloat16_t>(1.0bf16, 2.0bf16));
123 complex<float64_t> e16 = complex<bfloat16_t>(1.0bf16, 2.0bf16);
124 #endif
125 complex<float128_t> f01(complex<float>(1.0f, 2.0f));
126 complex<float128_t> f02 = complex<float>(1.0f, 2.0f);
127 complex<float128_t> f03(complex<double>(1.0, 2.0));
128 complex<float128_t> f04 = complex<double>(1.0, 2.0);
129 complex<float128_t> f05(complex<long double>(1.0L, 2.0L));
130 complex<float128_t> f06 = complex<long double>(1.0L, 2.0L);
131 complex<float128_t> f07(complex<float32_t>(1.0f32, 2.0f32));
132 complex<float128_t> f08 = complex<float32_t>(1.0f32, 2.0f32);
133 complex<float128_t> f09(complex<float64_t>(1.0f64, 2.0f64));
134 complex<float128_t> f10 = complex<float64_t>(1.0f64, 2.0f64);
135 complex<float128_t> f11(complex<float128_t>(1.0f128, 2.0f128));
136 complex<float128_t> f12 = complex<float128_t>(1.0f128, 2.0f128);
137 #ifdef __STDCPP_FLOAT16_T__
138 complex<float128_t> f13(complex<float16_t>(1.0f16, 2.0f16));
139 complex<float128_t> f14 = complex<float16_t>(1.0f16, 2.0f16);
140 #endif
141 #ifdef __STDCPP_BFLOAT16_T__
142 complex<float128_t> f15(complex<bfloat16_t>(1.0bf16, 2.0bf16));
143 complex<float128_t> f16 = complex<bfloat16_t>(1.0bf16, 2.0bf16);
144 #endif
145 #ifdef __STDCPP_FLOAT16_T__
146 complex<float16_t> g01(complex<float>(1.0f, 2.0f));
147 complex<float16_t> g02 = complex<float>(1.0f, 2.0f); // { dg-error "conversion from 'complex<float>' to non-scalar type 'complex<_Float16>' requested" "" { target float16 } }
148 complex<float16_t> g03(complex<double>(1.0, 2.0));
149 complex<float16_t> g04 = complex<double>(1.0, 2.0); // { dg-error "conversion from 'complex<double>' to non-scalar type 'complex<_Float16>' requested" "" { target float16 } }
150 complex<float16_t> g05(complex<long double>(1.0L, 2.0L));
151 complex<float16_t> g06 = complex<long double>(1.0L, 2.0L); // { dg-error "conversion from 'complex<long double>' to non-scalar type 'complex<_Float16>' requested" "" { target float16 } }
152 complex<float16_t> g07(complex<float32_t>(1.0f32, 2.0f32));
153 complex<float16_t> g08 = complex<float32_t>(1.0f32, 2.0f32); // { dg-error "conversion from 'complex<_Float32>' to non-scalar type 'complex<_Float16>' requested" "" { target float16 } }
154 complex<float16_t> g09(complex<float64_t>(1.0f64, 2.0f64));
155 complex<float16_t> g10 = complex<float64_t>(1.0f64, 2.0f64); // { dg-error "conversion from 'complex<_Float64>' to non-scalar type 'complex<_Float16>' requested" "" { target float16 } }
156 complex<float16_t> g11(complex<float128_t>(1.0f128, 2.0f128));
157 complex<float16_t> g12 = complex<float128_t>(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex<_Float16>' requested" "" { target float16 } }
158 complex<float16_t> g13(complex<float16_t>(1.0f16, 2.0f16));
159 complex<float16_t> g14 = complex<float16_t>(1.0f16, 2.0f16);
160 #ifdef __STDCPP_BFLOAT16_T__
161 complex<float16_t> g15(complex<bfloat16_t>(1.0bf16, 2.0bf16));
162 complex<float16_t> g16 = complex<bfloat16_t>(1.0bf16, 2.0bf16); // { dg-error "conversion from 'complex<\[^\n\r]*>' to non-scalar type 'complex<_Float16>' requested" "" { target { float16 && bfloat16 } } }
163 #endif
164 #endif
165 #ifdef __STDCPP_BFLOAT16_T__
166 complex<bfloat16_t> h01(complex<float>(1.0f, 2.0f));
167 complex<bfloat16_t> h02 = complex<float>(1.0f, 2.0f); // { dg-error "conversion from 'complex<float>' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target bfloat16 } }
168 complex<bfloat16_t> h03(complex<double>(1.0, 2.0));
169 complex<bfloat16_t> h04 = complex<double>(1.0, 2.0); // { dg-error "conversion from 'complex<double>' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target bfloat16 } }
170 complex<bfloat16_t> h05(complex<long double>(1.0L, 2.0L));
171 complex<bfloat16_t> h06 = complex<long double>(1.0L, 2.0L); // { dg-error "conversion from 'complex<long double>' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target bfloat16 } }
172 complex<bfloat16_t> h07(complex<float32_t>(1.0f32, 2.0f32));
173 complex<bfloat16_t> h08 = complex<float32_t>(1.0f32, 2.0f32); // { dg-error "conversion from 'complex<_Float32>' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target bfloat16 } }
174 complex<bfloat16_t> h09(complex<float64_t>(1.0f64, 2.0f64));
175 complex<bfloat16_t> h10 = complex<float64_t>(1.0f64, 2.0f64); // { dg-error "conversion from 'complex<_Float64>' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target bfloat16 } }
176 complex<bfloat16_t> h11(complex<float128_t>(1.0f128, 2.0f128));
177 complex<bfloat16_t> h12 = complex<float128_t>(1.0f128, 2.0f128); // { dg-error "conversion from 'complex<_Float128>' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target bfloat16 } }
178 #ifdef __STDCPP_FLOAT16_T__
179 complex<bfloat16_t> h13(complex<float16_t>(1.0f16, 2.0f16));
180 complex<bfloat16_t> h14 = complex<float16_t>(1.0f16, 2.0f16); // { dg-error "conversion from 'complex<_Float16>' to non-scalar type 'complex<\[^\n\r]*>' requested" "" { target { float16 && bfloat16 } } }
181 #endif
182 complex<bfloat16_t> h15(complex<bfloat16_t>(1.0bf16, 2.0bf16));
183 complex<bfloat16_t> h16 = complex<bfloat16_t>(1.0bf16, 2.0bf16);
184 #endif
185 }