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_maximum() { 80 const float a = 2.0f; 81 float b = 1.0f; 82 static_assert(!is_const<decltype(__builtin_elementwise_maximum(a, b))>::value); 83 static_assert(!is_const<decltype(__builtin_elementwise_maximum(b, a))>::value); 84 static_assert(!is_const<decltype(__builtin_elementwise_maximum(a, a))>::value); 85 } 86 87 void test_builtin_elementwise_minimum() { 88 const float a = 2.0f; 89 float b = 1.0f; 90 static_assert(!is_const<decltype(__builtin_elementwise_minimum(a, b))>::value); 91 static_assert(!is_const<decltype(__builtin_elementwise_minimum(b, a))>::value); 92 static_assert(!is_const<decltype(__builtin_elementwise_minimum(a, a))>::value); 93 } 94 95 void test_builtin_elementwise_ceil() { 96 const float a = 42.0; 97 float b = 42.3; 98 static_assert(!is_const<decltype(__builtin_elementwise_ceil(a))>::value); 99 static_assert(!is_const<decltype(__builtin_elementwise_ceil(b))>::value); 100 } 101 102 void test_builtin_elementwise_acos() { 103 const float a = 42.0; 104 float b = 42.3; 105 static_assert(!is_const<decltype(__builtin_elementwise_acos(a))>::value); 106 static_assert(!is_const<decltype(__builtin_elementwise_acos(b))>::value); 107 } 108 109 void test_builtin_elementwise_cos() { 110 const float a = 42.0; 111 float b = 42.3; 112 static_assert(!is_const<decltype(__builtin_elementwise_cos(a))>::value); 113 static_assert(!is_const<decltype(__builtin_elementwise_cos(b))>::value); 114 } 115 116 void test_builtin_elementwise_cosh() { 117 const float a = 42.0; 118 float b = 42.3; 119 static_assert(!is_const<decltype(__builtin_elementwise_cosh(a))>::value); 120 static_assert(!is_const<decltype(__builtin_elementwise_cosh(b))>::value); 121 } 122 123 void test_builtin_elementwise_exp() { 124 const float a = 42.0; 125 float b = 42.3; 126 static_assert(!is_const<decltype(__builtin_elementwise_exp(a))>::value); 127 static_assert(!is_const<decltype(__builtin_elementwise_exp(b))>::value); 128 } 129 130 void test_builtin_elementwise_exp2() { 131 const float a = 42.0; 132 float b = 42.3; 133 static_assert(!is_const<decltype(__builtin_elementwise_exp2(a))>::value); 134 static_assert(!is_const<decltype(__builtin_elementwise_exp2(b))>::value); 135 } 136 137 void test_builtin_elementwise_asin() { 138 const float a = 42.0; 139 float b = 42.3; 140 static_assert(!is_const<decltype(__builtin_elementwise_asin(a))>::value); 141 static_assert(!is_const<decltype(__builtin_elementwise_asin(b))>::value); 142 } 143 144 void test_builtin_elementwise_sin() { 145 const float a = 42.0; 146 float b = 42.3; 147 static_assert(!is_const<decltype(__builtin_elementwise_sin(a))>::value); 148 static_assert(!is_const<decltype(__builtin_elementwise_sin(b))>::value); 149 } 150 151 void test_builtin_elementwise_sinh() { 152 const float a = 42.0; 153 float b = 42.3; 154 static_assert(!is_const<decltype(__builtin_elementwise_sinh(a))>::value); 155 static_assert(!is_const<decltype(__builtin_elementwise_sinh(b))>::value); 156 } 157 158 void test_builtin_elementwise_atan() { 159 const float a = 42.0; 160 float b = 42.3; 161 static_assert(!is_const<decltype(__builtin_elementwise_atan(a))>::value); 162 static_assert(!is_const<decltype(__builtin_elementwise_atan(b))>::value); 163 } 164 165 void test_builtin_elementwise_atan2() { 166 const float a = 42.0; 167 float b = 42.3; 168 static_assert(!is_const<decltype(__builtin_elementwise_atan2(a, a))>::value); 169 static_assert(!is_const<decltype(__builtin_elementwise_atan2(b, b))>::value); 170 } 171 172 void test_builtin_elementwise_tan() { 173 const float a = 42.0; 174 float b = 42.3; 175 static_assert(!is_const<decltype(__builtin_elementwise_tan(a))>::value); 176 static_assert(!is_const<decltype(__builtin_elementwise_tan(b))>::value); 177 } 178 179 void test_builtin_elementwise_tanh() { 180 const float a = 42.0; 181 float b = 42.3; 182 static_assert(!is_const<decltype(__builtin_elementwise_tanh(a))>::value); 183 static_assert(!is_const<decltype(__builtin_elementwise_tanh(b))>::value); 184 } 185 186 void test_builtin_elementwise_sqrt() { 187 const float a = 42.0; 188 float b = 42.3; 189 static_assert(!is_const<decltype(__builtin_elementwise_sqrt(a))>::value); 190 static_assert(!is_const<decltype(__builtin_elementwise_sqrt(b))>::value); 191 } 192 193 void test_builtin_elementwise_log() { 194 const float a = 42.0; 195 float b = 42.3; 196 static_assert(!is_const<decltype(__builtin_elementwise_log(a))>::value); 197 static_assert(!is_const<decltype(__builtin_elementwise_log(b))>::value); 198 } 199 200 void test_builtin_elementwise_log10() { 201 const float a = 42.0; 202 float b = 42.3; 203 static_assert(!is_const<decltype(__builtin_elementwise_log10(a))>::value); 204 static_assert(!is_const<decltype(__builtin_elementwise_log10(b))>::value); 205 } 206 207 void test_builtin_elementwise_log2() { 208 const float a = 42.0; 209 float b = 42.3; 210 static_assert(!is_const<decltype(__builtin_elementwise_log2(a))>::value); 211 static_assert(!is_const<decltype(__builtin_elementwise_log2(b))>::value); 212 } 213 214 void test_builtin_elementwise_rint() { 215 const float a = 42.5; 216 float b = 42.3; 217 static_assert(!is_const<decltype(__builtin_elementwise_rint(a))>::value); 218 static_assert(!is_const<decltype(__builtin_elementwise_rint(b))>::value); 219 } 220 221 void test_builtin_elementwise_nearbyint() { 222 const float a = 42.5; 223 float b = 42.3; 224 static_assert(!is_const<decltype(__builtin_elementwise_nearbyint(a))>::value); 225 static_assert(!is_const<decltype(__builtin_elementwise_nearbyint(b))>::value); 226 } 227 228 void test_builtin_elementwise_round() { 229 const float a = 42.5; 230 float b = 42.3; 231 static_assert(!is_const<decltype(__builtin_elementwise_round(a))>::value); 232 static_assert(!is_const<decltype(__builtin_elementwise_round(b))>::value); 233 } 234 235 void test_builtin_elementwise_roundeven() { 236 const float a = 42.5; 237 float b = 42.3; 238 static_assert(!is_const<decltype(__builtin_elementwise_roundeven(a))>::value); 239 static_assert(!is_const<decltype(__builtin_elementwise_roundeven(b))>::value); 240 } 241 242 void test_builtin_elementwise_trunc() { 243 const float a = 42.5; 244 float b = 42.3; 245 static_assert(!is_const<decltype(__builtin_elementwise_trunc(a))>::value); 246 static_assert(!is_const<decltype(__builtin_elementwise_trunc(b))>::value); 247 } 248 249 void test_builtin_elementwise_floor() { 250 const float a = 42.5; 251 float b = 42.3; 252 static_assert(!is_const<decltype(__builtin_elementwise_floor(a))>::value); 253 static_assert(!is_const<decltype(__builtin_elementwise_floor(b))>::value); 254 } 255 256 void test_builtin_elementwise_canonicalize() { 257 const float a = 42.5; 258 float b = 42.3; 259 static_assert(!is_const<decltype(__builtin_elementwise_canonicalize(a))>::value); 260 static_assert(!is_const<decltype(__builtin_elementwise_canonicalize(b))>::value); 261 } 262 263 void test_builtin_elementwise_copysign() { 264 const float a = 2.0f; 265 float b = -4.0f; 266 static_assert(!is_const<decltype(__builtin_elementwise_copysign(a, b))>::value); 267 static_assert(!is_const<decltype(__builtin_elementwise_copysign(b, a))>::value); 268 static_assert(!is_const<decltype(__builtin_elementwise_copysign(a, a))>::value); 269 } 270 271 void test_builtin_elementwise_fma() { 272 const float a = 2.0f; 273 float b = -4.0f; 274 float c = 1.0f; 275 static_assert(!is_const<decltype(__builtin_elementwise_fma(a, a, a))>::value); 276 static_assert(!is_const<decltype(__builtin_elementwise_fma(a, b, c))>::value); 277 static_assert(!is_const<decltype(__builtin_elementwise_fma(b, a, c))>::value); 278 static_assert(!is_const<decltype(__builtin_elementwise_fma(c, c, c))>::value); 279 } 280 281 void test_builtin_elementwise_fmod() { 282 const double a = 2; 283 double b = 1; 284 static_assert(!is_const<decltype(__builtin_elementwise_fmod(a, b))>::value); 285 static_assert(!is_const<decltype(__builtin_elementwise_fmod(b, a))>::value); 286 static_assert(!is_const<decltype(__builtin_elementwise_fmod(a, a))>::value); 287 } 288 289 void test_builtin_elementwise_pow() { 290 const double a = 2; 291 double b = 1; 292 static_assert(!is_const<decltype(__builtin_elementwise_pow(a, b))>::value); 293 static_assert(!is_const<decltype(__builtin_elementwise_pow(b, a))>::value); 294 static_assert(!is_const<decltype(__builtin_elementwise_pow(a, a))>::value); 295 } 296 297 void test_builtin_elementwise_bitreverse() { 298 const int a = 2; 299 int b = 1; 300 static_assert(!is_const<decltype(__builtin_elementwise_bitreverse(a))>::value); 301 static_assert(!is_const<decltype(__builtin_elementwise_bitreverse(b))>::value); 302 } 303 304 void test_builtin_elementwise_popcount() { 305 const int a = 2; 306 int b = 1; 307 static_assert(!is_const<decltype(__builtin_elementwise_popcount(a))>::value); 308 static_assert(!is_const<decltype(__builtin_elementwise_popcount(b))>::value); 309 } 310 311