1 // RUN: %clang_cc1 %s -std=c++17 -pedantic -verify -triple=x86_64-apple-darwin9
3 // Simple is_const implementation.
5 static const bool value
= true;
9 static const bool value
= false;
12 template <class T
> struct is_const
: false_type
{};
13 template <class T
> struct is_const
<const T
> : true_type
{};
15 // expected-no-diagnostics
17 void test_builtin_elementwise_abs() {
20 static_assert(!is_const
<decltype(__builtin_elementwise_abs(a
))>::value
);
21 static_assert(!is_const
<decltype(__builtin_elementwise_abs(b
))>::value
);
24 void test_builtin_elementwise_abs_fp() {
25 const float a
= -2.0f
;
27 static_assert(!is_const
<decltype(__builtin_elementwise_abs(a
))>::value
);
28 static_assert(!is_const
<decltype(__builtin_elementwise_abs(b
))>::value
);
31 void test_builtin_elementwise_add_sat() {
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
);
39 void test_builtin_elementwise_sub_sat() {
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
);
47 void test_builtin_elementwise_max() {
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
);
55 void test_builtin_elementwise_min() {
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
);
63 void test_builtin_elementwise_max_fp() {
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
);
71 void test_builtin_elementwise_min_fp() {
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
);
79 void test_builtin_elementwise_ceil() {
82 static_assert(!is_const
<decltype(__builtin_elementwise_ceil(a
))>::value
);
83 static_assert(!is_const
<decltype(__builtin_elementwise_ceil(b
))>::value
);
86 void test_builtin_elementwise_cos() {
89 static_assert(!is_const
<decltype(__builtin_elementwise_cos(a
))>::value
);
90 static_assert(!is_const
<decltype(__builtin_elementwise_cos(b
))>::value
);
93 void test_builtin_elementwise_exp() {
96 static_assert(!is_const
<decltype(__builtin_elementwise_exp(a
))>::value
);
97 static_assert(!is_const
<decltype(__builtin_elementwise_exp(b
))>::value
);
100 void test_builtin_elementwise_exp2() {
101 const float a
= 42.0;
103 static_assert(!is_const
<decltype(__builtin_elementwise_exp2(a
))>::value
);
104 static_assert(!is_const
<decltype(__builtin_elementwise_exp2(b
))>::value
);
107 void test_builtin_elementwise_sin() {
108 const float a
= 42.0;
110 static_assert(!is_const
<decltype(__builtin_elementwise_sin(a
))>::value
);
111 static_assert(!is_const
<decltype(__builtin_elementwise_sin(b
))>::value
);
114 void test_builtin_elementwise_sqrt() {
115 const float a
= 42.0;
117 static_assert(!is_const
<decltype(__builtin_elementwise_sqrt(a
))>::value
);
118 static_assert(!is_const
<decltype(__builtin_elementwise_sqrt(b
))>::value
);
121 void test_builtin_elementwise_log() {
122 const float a
= 42.0;
124 static_assert(!is_const
<decltype(__builtin_elementwise_log(a
))>::value
);
125 static_assert(!is_const
<decltype(__builtin_elementwise_log(b
))>::value
);
128 void test_builtin_elementwise_log10() {
129 const float a
= 42.0;
131 static_assert(!is_const
<decltype(__builtin_elementwise_log10(a
))>::value
);
132 static_assert(!is_const
<decltype(__builtin_elementwise_log10(b
))>::value
);
135 void test_builtin_elementwise_log2() {
136 const float a
= 42.0;
138 static_assert(!is_const
<decltype(__builtin_elementwise_log2(a
))>::value
);
139 static_assert(!is_const
<decltype(__builtin_elementwise_log2(b
))>::value
);
142 void test_builtin_elementwise_rint() {
143 const float a
= 42.5;
145 static_assert(!is_const
<decltype(__builtin_elementwise_rint(a
))>::value
);
146 static_assert(!is_const
<decltype(__builtin_elementwise_rint(b
))>::value
);
149 void test_builtin_elementwise_nearbyint() {
150 const float a
= 42.5;
152 static_assert(!is_const
<decltype(__builtin_elementwise_nearbyint(a
))>::value
);
153 static_assert(!is_const
<decltype(__builtin_elementwise_nearbyint(b
))>::value
);
156 void test_builtin_elementwise_round() {
157 const float a
= 42.5;
159 static_assert(!is_const
<decltype(__builtin_elementwise_round(a
))>::value
);
160 static_assert(!is_const
<decltype(__builtin_elementwise_round(b
))>::value
);
163 void test_builtin_elementwise_roundeven() {
164 const float a
= 42.5;
166 static_assert(!is_const
<decltype(__builtin_elementwise_roundeven(a
))>::value
);
167 static_assert(!is_const
<decltype(__builtin_elementwise_roundeven(b
))>::value
);
170 void test_builtin_elementwise_trunc() {
171 const float a
= 42.5;
173 static_assert(!is_const
<decltype(__builtin_elementwise_trunc(a
))>::value
);
174 static_assert(!is_const
<decltype(__builtin_elementwise_trunc(b
))>::value
);
177 void test_builtin_elementwise_floor() {
178 const float a
= 42.5;
180 static_assert(!is_const
<decltype(__builtin_elementwise_floor(a
))>::value
);
181 static_assert(!is_const
<decltype(__builtin_elementwise_floor(b
))>::value
);
184 void test_builtin_elementwise_canonicalize() {
185 const float a
= 42.5;
187 static_assert(!is_const
<decltype(__builtin_elementwise_canonicalize(a
))>::value
);
188 static_assert(!is_const
<decltype(__builtin_elementwise_canonicalize(b
))>::value
);
191 void test_builtin_elementwise_copysign() {
192 const float a
= 2.0f
;
194 static_assert(!is_const
<decltype(__builtin_elementwise_copysign(a
, b
))>::value
);
195 static_assert(!is_const
<decltype(__builtin_elementwise_copysign(b
, a
))>::value
);
196 static_assert(!is_const
<decltype(__builtin_elementwise_copysign(a
, a
))>::value
);
199 void test_builtin_elementwise_fma() {
200 const float a
= 2.0f
;
203 static_assert(!is_const
<decltype(__builtin_elementwise_fma(a
, a
, a
))>::value
);
204 static_assert(!is_const
<decltype(__builtin_elementwise_fma(a
, b
, c
))>::value
);
205 static_assert(!is_const
<decltype(__builtin_elementwise_fma(b
, a
, c
))>::value
);
206 static_assert(!is_const
<decltype(__builtin_elementwise_fma(c
, c
, c
))>::value
);
209 void test_builtin_elementwise_pow() {
212 static_assert(!is_const
<decltype(__builtin_elementwise_pow(a
, b
))>::value
);
213 static_assert(!is_const
<decltype(__builtin_elementwise_pow(b
, a
))>::value
);
214 static_assert(!is_const
<decltype(__builtin_elementwise_pow(a
, a
))>::value
);
217 void test_builtin_elementwise_bitreverse() {
220 static_assert(!is_const
<decltype(__builtin_elementwise_bitreverse(a
))>::value
);
221 static_assert(!is_const
<decltype(__builtin_elementwise_bitreverse(b
))>::value
);