Debian Codegraph @

clang/test/SemaCXX/builtins-elementwise-math.cpp

raw
1 // RUN: %clang_cc1 %s -std=c++17 -pedantic -verify -triple=x86_64-apple-darwin9
2
3 // Simple is_const implementation.
4 struct true_type {
5 static const bool value = true;
6 };
7
8 struct false_type {
9 static const bool value = false;
10 };
11
12 template <class T> struct is_const : false_type {};
13 template <class T> struct is_const<const T> : true_type {};
14
15 // expected-no-diagnostics
16
17 void test_builtin_elementwise_abs() {
18 const int a = 2;
19 int b = 1;
20 static_assert(!is_const<decltype(__builtin_elementwise_abs(a))>::value);
21 static_assert(!is_const<decltype(__builtin_elementwise_abs(b))>::value);
22 }
23
24 void test_builtin_elementwise_abs_fp() {
25 const float a = -2.0f;
26 float b = 1.0f;
27 static_assert(!is_const<decltype(__builtin_elementwise_abs(a))>::value);
28 static_assert(!is_const<decltype(__builtin_elementwise_abs(b))>::value);
29 }
30
31 void test_builtin_elementwise_add_sat() {
32 const int a = 2;
33 int b = 1;
34 static_assert(!is_const<decltype(__builtin_elementwise_add_sat(a, b))>::value);
35 static_assert(!is_const<decltype(__builtin_elementwise_add_sat(b, a))>::value);
36 static_assert(!is_const<decltype(__builtin_elementwise_add_sat(a, a))>::value);
37 }
38
39 void test_builtin_elementwise_sub_sat() {
40 const int a = 2;
41 int b = 1;
42 static_assert(!is_const<decltype(__builtin_elementwise_sub_sat(a, b))>::value);
43 static_assert(!is_const<decltype(__builtin_elementwise_sub_sat(b, a))>::value);
44 static_assert(!is_const<decltype(__builtin_elementwise_sub_sat(a, a))>::value);
45 }
46
47 void test_builtin_elementwise_max() {
48 const int a = 2;
49 int b = 1;
50 static_assert(!is_const<decltype(__builtin_elementwise_max(a, b))>::value);
51 static_assert(!is_const<decltype(__builtin_elementwise_max(b, a))>::value);
52 static_assert(!is_const<decltype(__builtin_elementwise_max(a, a))>::value);
53 }
54
55 void test_builtin_elementwise_min() {
56 const int a = 2;
57 int b = 1;
58 static_assert(!is_const<decltype(__builtin_elementwise_min(a, b))>::value);
59 static_assert(!is_const<decltype(__builtin_elementwise_min(b, a))>::value);
60 static_assert(!is_const<decltype(__builtin_elementwise_min(a, a))>::value);
61 }
62
63 void test_builtin_elementwise_max_fp() {
64 const float a = 2.0f;
65 float b = 1.0f;
66 static_assert(!is_const<decltype(__builtin_elementwise_max(a, b))>::value);
67 static_assert(!is_const<decltype(__builtin_elementwise_max(b, a))>::value);
68 static_assert(!is_const<decltype(__builtin_elementwise_max(a, a))>::value);
69 }
70
71 void test_builtin_elementwise_min_fp() {
72 const float a = 2.0f;
73 float b = 1.0f;
74 static_assert(!is_const<decltype(__builtin_elementwise_min(a, b))>::value);
75 static_assert(!is_const<decltype(__builtin_elementwise_min(b, a))>::value);
76 static_assert(!is_const<decltype(__builtin_elementwise_min(a, a))>::value);
77 }
78
79 void test_builtin_elementwise_ceil() {
80 const float a = 42.0;
81 float b = 42.3;
82 static_assert(!is_const<decltype(__builtin_elementwise_ceil(a))>::value);
83 static_assert(!is_const<decltype(__builtin_elementwise_ceil(b))>::value);
84 }
85
86 void test_builtin_elementwise_acos() {
87 const float a = 42.0;
88 float b = 42.3;
89 static_assert(!is_const<decltype(__builtin_elementwise_acos(a))>::value);
90 static_assert(!is_const<decltype(__builtin_elementwise_acos(b))>::value);
91 }
92
93 void test_builtin_elementwise_cos() {
94 const float a = 42.0;
95 float b = 42.3;
96 static_assert(!is_const<decltype(__builtin_elementwise_cos(a))>::value);
97 static_assert(!is_const<decltype(__builtin_elementwise_cos(b))>::value);
98 }
99
100 void test_builtin_elementwise_cosh() {
101 const float a = 42.0;
102 float b = 42.3;
103 static_assert(!is_const<decltype(__builtin_elementwise_cosh(a))>::value);
104 static_assert(!is_const<decltype(__builtin_elementwise_cosh(b))>::value);
105 }
106
107 void test_builtin_elementwise_exp() {
108 const float a = 42.0;
109 float b = 42.3;
110 static_assert(!is_const<decltype(__builtin_elementwise_exp(a))>::value);
111 static_assert(!is_const<decltype(__builtin_elementwise_exp(b))>::value);
112 }
113
114 void test_builtin_elementwise_exp2() {
115 const float a = 42.0;
116 float b = 42.3;
117 static_assert(!is_const<decltype(__builtin_elementwise_exp2(a))>::value);
118 static_assert(!is_const<decltype(__builtin_elementwise_exp2(b))>::value);
119 }
120
121 void test_builtin_elementwise_asin() {
122 const float a = 42.0;
123 float b = 42.3;
124 static_assert(!is_const<decltype(__builtin_elementwise_asin(a))>::value);
125 static_assert(!is_const<decltype(__builtin_elementwise_asin(b))>::value);
126 }
127
128 void test_builtin_elementwise_sin() {
129 const float a = 42.0;
130 float b = 42.3;
131 static_assert(!is_const<decltype(__builtin_elementwise_sin(a))>::value);
132 static_assert(!is_const<decltype(__builtin_elementwise_sin(b))>::value);
133 }
134
135 void test_builtin_elementwise_sinh() {
136 const float a = 42.0;
137 float b = 42.3;
138 static_assert(!is_const<decltype(__builtin_elementwise_sinh(a))>::value);
139 static_assert(!is_const<decltype(__builtin_elementwise_sinh(b))>::value);
140 }
141
142 void test_builtin_elementwise_atan() {
143 const float a = 42.0;
144 float b = 42.3;
145 static_assert(!is_const<decltype(__builtin_elementwise_atan(a))>::value);
146 static_assert(!is_const<decltype(__builtin_elementwise_atan(b))>::value);
147 }
148
149 void test_builtin_elementwise_tan() {
150 const float a = 42.0;
151 float b = 42.3;
152 static_assert(!is_const<decltype(__builtin_elementwise_tan(a))>::value);
153 static_assert(!is_const<decltype(__builtin_elementwise_tan(b))>::value);
154 }
155
156 void test_builtin_elementwise_tanh() {
157 const float a = 42.0;
158 float b = 42.3;
159 static_assert(!is_const<decltype(__builtin_elementwise_tanh(a))>::value);
160 static_assert(!is_const<decltype(__builtin_elementwise_tanh(b))>::value);
161 }
162
163 void test_builtin_elementwise_sqrt() {
164 const float a = 42.0;
165 float b = 42.3;
166 static_assert(!is_const<decltype(__builtin_elementwise_sqrt(a))>::value);
167 static_assert(!is_const<decltype(__builtin_elementwise_sqrt(b))>::value);
168 }
169
170 void test_builtin_elementwise_log() {
171 const float a = 42.0;
172 float b = 42.3;
173 static_assert(!is_const<decltype(__builtin_elementwise_log(a))>::value);
174 static_assert(!is_const<decltype(__builtin_elementwise_log(b))>::value);
175 }
176
177 void test_builtin_elementwise_log10() {
178 const float a = 42.0;
179 float b = 42.3;
180 static_assert(!is_const<decltype(__builtin_elementwise_log10(a))>::value);
181 static_assert(!is_const<decltype(__builtin_elementwise_log10(b))>::value);
182 }
183
184 void test_builtin_elementwise_log2() {
185 const float a = 42.0;
186 float b = 42.3;
187 static_assert(!is_const<decltype(__builtin_elementwise_log2(a))>::value);
188 static_assert(!is_const<decltype(__builtin_elementwise_log2(b))>::value);
189 }
190
191 void test_builtin_elementwise_rint() {
192 const float a = 42.5;
193 float b = 42.3;
194 static_assert(!is_const<decltype(__builtin_elementwise_rint(a))>::value);
195 static_assert(!is_const<decltype(__builtin_elementwise_rint(b))>::value);
196 }
197
198 void test_builtin_elementwise_nearbyint() {
199 const float a = 42.5;
200 float b = 42.3;
201 static_assert(!is_const<decltype(__builtin_elementwise_nearbyint(a))>::value);
202 static_assert(!is_const<decltype(__builtin_elementwise_nearbyint(b))>::value);
203 }
204
205 void test_builtin_elementwise_round() {
206 const float a = 42.5;
207 float b = 42.3;
208 static_assert(!is_const<decltype(__builtin_elementwise_round(a))>::value);
209 static_assert(!is_const<decltype(__builtin_elementwise_round(b))>::value);
210 }
211
212 void test_builtin_elementwise_roundeven() {
213 const float a = 42.5;
214 float b = 42.3;
215 static_assert(!is_const<decltype(__builtin_elementwise_roundeven(a))>::value);
216 static_assert(!is_const<decltype(__builtin_elementwise_roundeven(b))>::value);
217 }
218
219 void test_builtin_elementwise_trunc() {
220 const float a = 42.5;
221 float b = 42.3;
222 static_assert(!is_const<decltype(__builtin_elementwise_trunc(a))>::value);
223 static_assert(!is_const<decltype(__builtin_elementwise_trunc(b))>::value);
224 }
225
226 void test_builtin_elementwise_floor() {
227 const float a = 42.5;
228 float b = 42.3;
229 static_assert(!is_const<decltype(__builtin_elementwise_floor(a))>::value);
230 static_assert(!is_const<decltype(__builtin_elementwise_floor(b))>::value);
231 }
232
233 void test_builtin_elementwise_canonicalize() {
234 const float a = 42.5;
235 float b = 42.3;
236 static_assert(!is_const<decltype(__builtin_elementwise_canonicalize(a))>::value);
237 static_assert(!is_const<decltype(__builtin_elementwise_canonicalize(b))>::value);
238 }
239
240 void test_builtin_elementwise_copysign() {
241 const float a = 2.0f;
242 float b = -4.0f;
243 static_assert(!is_const<decltype(__builtin_elementwise_copysign(a, b))>::value);
244 static_assert(!is_const<decltype(__builtin_elementwise_copysign(b, a))>::value);
245 static_assert(!is_const<decltype(__builtin_elementwise_copysign(a, a))>::value);
246 }
247
248 void test_builtin_elementwise_fma() {
249 const float a = 2.0f;
250 float b = -4.0f;
251 float c = 1.0f;
252 static_assert(!is_const<decltype(__builtin_elementwise_fma(a, a, a))>::value);
253 static_assert(!is_const<decltype(__builtin_elementwise_fma(a, b, c))>::value);
254 static_assert(!is_const<decltype(__builtin_elementwise_fma(b, a, c))>::value);
255 static_assert(!is_const<decltype(__builtin_elementwise_fma(c, c, c))>::value);
256 }
257
258 void test_builtin_elementwise_pow() {
259 const double a = 2;
260 double b = 1;
261 static_assert(!is_const<decltype(__builtin_elementwise_pow(a, b))>::value);
262 static_assert(!is_const<decltype(__builtin_elementwise_pow(b, a))>::value);
263 static_assert(!is_const<decltype(__builtin_elementwise_pow(a, a))>::value);
264 }
265
266 void test_builtin_elementwise_bitreverse() {
267 const int a = 2;
268 int b = 1;
269 static_assert(!is_const<decltype(__builtin_elementwise_bitreverse(a))>::value);
270 static_assert(!is_const<decltype(__builtin_elementwise_bitreverse(b))>::value);
271 }