1 // RUN: %clang_cc1 -std=c99 %s -pedantic -verify -triple=x86_64-apple-darwin9 2 3 typedef double double2 __attribute__((ext_vector_type(2))); 4 typedef double double4 __attribute__((ext_vector_type(4))); 5 typedef float float2 __attribute__((ext_vector_type(2))); 6 typedef float float4 __attribute__((ext_vector_type(4))); 7 8 typedef int int2 __attribute__((ext_vector_type(2))); 9 typedef int int3 __attribute__((ext_vector_type(3))); 10 typedef unsigned unsigned3 __attribute__((ext_vector_type(3))); 11 typedef unsigned unsigned4 __attribute__((ext_vector_type(4))); 12 13 struct Foo { 14 char *p; 15 }; 16 17 __attribute__((address_space(1))) int int_as_one; 18 typedef int bar; 19 bar b; 20 21 __attribute__((address_space(1))) float float_as_one; 22 typedef float waffle; 23 waffle waf; 24 25 26 void test_builtin_elementwise_abs(int i, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 27 struct Foo s = __builtin_elementwise_abs(i); 28 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}} 29 30 i = __builtin_elementwise_abs(); 31 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 32 33 i = __builtin_elementwise_abs(i, i); 34 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 35 36 i = __builtin_elementwise_abs(v); 37 // expected-error@-1 {{assigning to 'int' from incompatible type 'float4' (vector of 4 'float' values)}} 38 39 u = __builtin_elementwise_abs(u); 40 // expected-error@-1 {{1st argument must be a signed integer or floating point type (was 'unsigned int')}} 41 42 uv = __builtin_elementwise_abs(uv); 43 // expected-error@-1 {{1st argument must be a signed integer or floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 44 } 45 46 void test_builtin_elementwise_add_sat(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) { 47 i = __builtin_elementwise_add_sat(p, d); 48 // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}} 49 50 struct Foo foo = __builtin_elementwise_add_sat(i, i); 51 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}} 52 53 i = __builtin_elementwise_add_sat(i); 54 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} 55 56 i = __builtin_elementwise_add_sat(); 57 // expected-error@-1 {{too few arguments to function call, expected 2, have 0}} 58 59 i = __builtin_elementwise_add_sat(i, i, i); 60 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} 61 62 i = __builtin_elementwise_add_sat(v, iv); 63 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}} 64 65 i = __builtin_elementwise_add_sat(uv, iv); 66 // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}} 67 68 v = __builtin_elementwise_add_sat(v, v); 69 // expected-error@-1 {{1st argument must be a vector of integers (was 'float4' (vector of 4 'float' values))}} 70 71 s = __builtin_elementwise_add_sat(i, s); 72 73 enum e { one, 74 two }; 75 i = __builtin_elementwise_add_sat(one, two); 76 77 enum f { three }; 78 enum f x = __builtin_elementwise_add_sat(one, three); 79 80 _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}} 81 ext = __builtin_elementwise_add_sat(ext, ext); 82 83 const int ci; 84 i = __builtin_elementwise_add_sat(ci, i); 85 i = __builtin_elementwise_add_sat(i, ci); 86 i = __builtin_elementwise_add_sat(ci, ci); 87 88 i = __builtin_elementwise_add_sat(i, int_as_one); // ok (attributes don't match)? 89 i = __builtin_elementwise_add_sat(i, b); // ok (sugar doesn't match)? 90 91 int A[10]; 92 A = __builtin_elementwise_add_sat(A, A); 93 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}} 94 95 int(ii); 96 int j; 97 j = __builtin_elementwise_add_sat(i, j); 98 99 _Complex float c1, c2; 100 c1 = __builtin_elementwise_add_sat(c1, c2); 101 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} 102 } 103 104 void test_builtin_elementwise_sub_sat(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) { 105 i = __builtin_elementwise_sub_sat(p, d); 106 // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}} 107 108 struct Foo foo = __builtin_elementwise_sub_sat(i, i); 109 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}} 110 111 i = __builtin_elementwise_sub_sat(i); 112 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} 113 114 i = __builtin_elementwise_sub_sat(); 115 // expected-error@-1 {{too few arguments to function call, expected 2, have 0}} 116 117 i = __builtin_elementwise_sub_sat(i, i, i); 118 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} 119 120 i = __builtin_elementwise_sub_sat(v, iv); 121 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}} 122 123 i = __builtin_elementwise_sub_sat(uv, iv); 124 // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}} 125 126 v = __builtin_elementwise_sub_sat(v, v); 127 // expected-error@-1 {{1st argument must be a vector of integers (was 'float4' (vector of 4 'float' values))}} 128 129 s = __builtin_elementwise_sub_sat(i, s); 130 131 enum e { one, 132 two }; 133 i = __builtin_elementwise_sub_sat(one, two); 134 135 enum f { three }; 136 enum f x = __builtin_elementwise_sub_sat(one, three); 137 138 _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}} 139 ext = __builtin_elementwise_sub_sat(ext, ext); 140 141 const int ci; 142 i = __builtin_elementwise_sub_sat(ci, i); 143 i = __builtin_elementwise_sub_sat(i, ci); 144 i = __builtin_elementwise_sub_sat(ci, ci); 145 146 i = __builtin_elementwise_sub_sat(i, int_as_one); // ok (attributes don't match)? 147 i = __builtin_elementwise_sub_sat(i, b); // ok (sugar doesn't match)? 148 149 int A[10]; 150 A = __builtin_elementwise_sub_sat(A, A); 151 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}} 152 153 int(ii); 154 int j; 155 j = __builtin_elementwise_sub_sat(i, j); 156 157 _Complex float c1, c2; 158 c1 = __builtin_elementwise_sub_sat(c1, c2); 159 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} 160 } 161 162 void test_builtin_elementwise_max(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) { 163 i = __builtin_elementwise_max(p, d); 164 // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}} 165 166 struct Foo foo = __builtin_elementwise_max(i, i); 167 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}} 168 169 i = __builtin_elementwise_max(i); 170 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} 171 172 i = __builtin_elementwise_max(); 173 // expected-error@-1 {{too few arguments to function call, expected 2, have 0}} 174 175 i = __builtin_elementwise_max(i, i, i); 176 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} 177 178 i = __builtin_elementwise_max(v, iv); 179 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}} 180 181 i = __builtin_elementwise_max(uv, iv); 182 // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}} 183 184 s = __builtin_elementwise_max(i, s); 185 186 enum e { one, 187 two }; 188 i = __builtin_elementwise_max(one, two); 189 190 enum f { three }; 191 enum f x = __builtin_elementwise_max(one, three); 192 193 _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}} 194 ext = __builtin_elementwise_max(ext, ext); 195 196 const int ci; 197 i = __builtin_elementwise_max(ci, i); 198 i = __builtin_elementwise_max(i, ci); 199 i = __builtin_elementwise_max(ci, ci); 200 201 i = __builtin_elementwise_max(i, int_as_one); // ok (attributes don't match)? 202 i = __builtin_elementwise_max(i, b); // ok (sugar doesn't match)? 203 204 int A[10]; 205 A = __builtin_elementwise_max(A, A); 206 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}} 207 208 int(ii); 209 int j; 210 j = __builtin_elementwise_max(i, j); 211 212 _Complex float c1, c2; 213 c1 = __builtin_elementwise_max(c1, c2); 214 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} 215 } 216 217 void test_builtin_elementwise_min(int i, short s, double d, float4 v, int3 iv, unsigned3 uv, int *p) { 218 i = __builtin_elementwise_min(p, d); 219 // expected-error@-1 {{arguments are of different types ('int *' vs 'double')}} 220 221 struct Foo foo = __builtin_elementwise_min(i, i); 222 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}} 223 224 i = __builtin_elementwise_min(i); 225 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} 226 227 i = __builtin_elementwise_min(); 228 // expected-error@-1 {{too few arguments to function call, expected 2, have 0}} 229 230 i = __builtin_elementwise_min(i, i, i); 231 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} 232 233 i = __builtin_elementwise_min(v, iv); 234 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}} 235 236 i = __builtin_elementwise_min(uv, iv); 237 // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}} 238 239 s = __builtin_elementwise_min(i, s); 240 241 enum e { one, 242 two }; 243 i = __builtin_elementwise_min(one, two); 244 245 enum f { three }; 246 enum f x = __builtin_elementwise_min(one, three); 247 248 _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}} 249 ext = __builtin_elementwise_min(ext, ext); 250 251 const int ci; 252 i = __builtin_elementwise_min(ci, i); 253 i = __builtin_elementwise_min(i, ci); 254 i = __builtin_elementwise_min(ci, ci); 255 256 i = __builtin_elementwise_min(i, int_as_one); // ok (attributes don't match)? 257 i = __builtin_elementwise_min(i, b); // ok (sugar doesn't match)? 258 259 int A[10]; 260 A = __builtin_elementwise_min(A, A); 261 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}} 262 263 int(ii); 264 int j; 265 j = __builtin_elementwise_min(i, j); 266 267 _Complex float c1, c2; 268 c1 = __builtin_elementwise_min(c1, c2); 269 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} 270 } 271 272 void test_builtin_elementwise_ceil(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 273 274 struct Foo s = __builtin_elementwise_ceil(f); 275 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 276 277 i = __builtin_elementwise_ceil(); 278 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 279 280 i = __builtin_elementwise_ceil(i); 281 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 282 283 i = __builtin_elementwise_ceil(f, f); 284 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 285 286 u = __builtin_elementwise_ceil(u); 287 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 288 289 uv = __builtin_elementwise_ceil(uv); 290 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 291 } 292 293 void test_builtin_elementwise_cos(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 294 295 struct Foo s = __builtin_elementwise_cos(f); 296 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 297 298 i = __builtin_elementwise_cos(); 299 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 300 301 i = __builtin_elementwise_cos(i); 302 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 303 304 i = __builtin_elementwise_cos(f, f); 305 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 306 307 u = __builtin_elementwise_cos(u); 308 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 309 310 uv = __builtin_elementwise_cos(uv); 311 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 312 } 313 314 void test_builtin_elementwise_exp(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 315 316 struct Foo s = __builtin_elementwise_exp(f); 317 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 318 319 i = __builtin_elementwise_exp(); 320 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 321 322 i = __builtin_elementwise_exp(i); 323 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 324 325 i = __builtin_elementwise_exp(f, f); 326 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 327 328 u = __builtin_elementwise_exp(u); 329 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 330 331 uv = __builtin_elementwise_exp(uv); 332 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 333 } 334 335 void test_builtin_elementwise_exp2(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 336 337 struct Foo s = __builtin_elementwise_exp2(f); 338 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 339 340 i = __builtin_elementwise_exp2(); 341 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 342 343 i = __builtin_elementwise_exp2(i); 344 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 345 346 i = __builtin_elementwise_exp2(f, f); 347 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 348 349 u = __builtin_elementwise_exp2(u); 350 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 351 352 uv = __builtin_elementwise_exp2(uv); 353 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 354 } 355 356 357 void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 358 359 struct Foo s = __builtin_elementwise_floor(f); 360 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 361 362 i = __builtin_elementwise_floor(); 363 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 364 365 i = __builtin_elementwise_floor(i); 366 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 367 368 i = __builtin_elementwise_floor(f, f); 369 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 370 371 u = __builtin_elementwise_floor(u); 372 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 373 374 uv = __builtin_elementwise_floor(uv); 375 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 376 } 377 378 void test_builtin_elementwise_log(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 379 380 struct Foo s = __builtin_elementwise_log(f); 381 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 382 383 i = __builtin_elementwise_log(); 384 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 385 386 i = __builtin_elementwise_log(i); 387 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 388 389 i = __builtin_elementwise_log(f, f); 390 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 391 392 u = __builtin_elementwise_log(u); 393 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 394 395 uv = __builtin_elementwise_log(uv); 396 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 397 } 398 399 void test_builtin_elementwise_log10(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 400 401 struct Foo s = __builtin_elementwise_log10(f); 402 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 403 404 i = __builtin_elementwise_log10(); 405 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 406 407 i = __builtin_elementwise_log10(i); 408 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 409 410 i = __builtin_elementwise_log10(f, f); 411 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 412 413 u = __builtin_elementwise_log10(u); 414 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 415 416 uv = __builtin_elementwise_log10(uv); 417 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 418 } 419 420 void test_builtin_elementwise_log2(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 421 422 struct Foo s = __builtin_elementwise_log2(f); 423 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 424 425 i = __builtin_elementwise_log2(); 426 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 427 428 i = __builtin_elementwise_log2(i); 429 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 430 431 i = __builtin_elementwise_log2(f, f); 432 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 433 434 u = __builtin_elementwise_log2(u); 435 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 436 437 uv = __builtin_elementwise_log2(uv); 438 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 439 } 440 441 void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 442 443 struct Foo s = __builtin_elementwise_roundeven(f); 444 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 445 446 i = __builtin_elementwise_roundeven(); 447 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 448 449 i = __builtin_elementwise_roundeven(i); 450 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 451 452 i = __builtin_elementwise_roundeven(f, f); 453 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 454 455 u = __builtin_elementwise_roundeven(u); 456 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 457 458 uv = __builtin_elementwise_roundeven(uv); 459 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 460 } 461 462 void test_builtin_elementwise_round(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 463 struct Foo s = __builtin_elementwise_round(f); 464 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 465 466 i = __builtin_elementwise_round(); 467 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 468 469 i = __builtin_elementwise_round(i); 470 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 471 472 i = __builtin_elementwise_round(f, f); 473 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 474 475 u = __builtin_elementwise_round(u); 476 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 477 478 uv = __builtin_elementwise_round(uv); 479 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 480 481 // FIXME: Error should not mention integer 482 _Complex float c1, c2; 483 c1 = __builtin_elementwise_round(c1); 484 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} 485 } 486 487 void test_builtin_elementwise_rint(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 488 struct Foo s = __builtin_elementwise_rint(f); 489 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 490 491 i = __builtin_elementwise_rint(); 492 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 493 494 i = __builtin_elementwise_rint(i); 495 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 496 497 i = __builtin_elementwise_rint(f, f); 498 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 499 500 u = __builtin_elementwise_rint(u); 501 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 502 503 uv = __builtin_elementwise_rint(uv); 504 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 505 506 // FIXME: Error should not mention integer 507 _Complex float c1, c2; 508 c1 = __builtin_elementwise_rint(c1); 509 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} 510 } 511 512 void test_builtin_elementwise_nearbyint(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 513 struct Foo s = __builtin_elementwise_nearbyint(f); 514 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 515 516 i = __builtin_elementwise_nearbyint(); 517 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 518 519 i = __builtin_elementwise_nearbyint(i); 520 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 521 522 i = __builtin_elementwise_nearbyint(f, f); 523 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 524 525 u = __builtin_elementwise_nearbyint(u); 526 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 527 528 uv = __builtin_elementwise_nearbyint(uv); 529 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 530 531 // FIXME: Error should not mention integer 532 _Complex float c1, c2; 533 c1 = __builtin_elementwise_nearbyint(c1); 534 // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}} 535 } 536 537 void test_builtin_elementwise_sin(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 538 539 struct Foo s = __builtin_elementwise_sin(f); 540 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 541 542 i = __builtin_elementwise_sin(); 543 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 544 545 i = __builtin_elementwise_sin(i); 546 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 547 548 i = __builtin_elementwise_sin(f, f); 549 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 550 551 u = __builtin_elementwise_sin(u); 552 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 553 554 uv = __builtin_elementwise_sin(uv); 555 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 556 } 557 558 void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 559 560 struct Foo s = __builtin_elementwise_trunc(f); 561 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 562 563 i = __builtin_elementwise_trunc(); 564 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 565 566 i = __builtin_elementwise_trunc(i); 567 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 568 569 i = __builtin_elementwise_trunc(f, f); 570 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 571 572 u = __builtin_elementwise_trunc(u); 573 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 574 575 uv = __builtin_elementwise_trunc(uv); 576 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 577 } 578 579 void test_builtin_elementwise_canonicalize(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) { 580 581 struct Foo s = __builtin_elementwise_canonicalize(f); 582 // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}} 583 584 i = __builtin_elementwise_canonicalize(); 585 // expected-error@-1 {{too few arguments to function call, expected 1, have 0}} 586 587 i = __builtin_elementwise_canonicalize(i); 588 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 589 590 i = __builtin_elementwise_canonicalize(f, f); 591 // expected-error@-1 {{too many arguments to function call, expected 1, have 2}} 592 593 u = __builtin_elementwise_canonicalize(u); 594 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}} 595 596 uv = __builtin_elementwise_canonicalize(uv); 597 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}} 598 } 599 600 void test_builtin_elementwise_copysign(int i, short s, double d, float f, float4 v, int3 iv, unsigned3 uv, int *p) { 601 i = __builtin_elementwise_copysign(p, d); 602 // expected-error@-1 {{1st argument must be a floating point type (was 'int *')}} 603 604 i = __builtin_elementwise_copysign(i, i); 605 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 606 607 i = __builtin_elementwise_copysign(i); 608 // expected-error@-1 {{too few arguments to function call, expected 2, have 1}} 609 610 i = __builtin_elementwise_copysign(); 611 // expected-error@-1 {{too few arguments to function call, expected 2, have 0}} 612 613 i = __builtin_elementwise_copysign(i, i, i); 614 // expected-error@-1 {{too many arguments to function call, expected 2, have 3}} 615 616 i = __builtin_elementwise_copysign(v, iv); 617 // expected-error@-1 {{2nd argument must be a floating point type (was 'int3' (vector of 3 'int' values))}} 618 619 i = __builtin_elementwise_copysign(uv, iv); 620 // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned3' (vector of 3 'unsigned int' values))}} 621 622 s = __builtin_elementwise_copysign(i, s); 623 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 624 625 f = __builtin_elementwise_copysign(f, i); 626 // expected-error@-1 {{2nd argument must be a floating point type (was 'int')}} 627 628 f = __builtin_elementwise_copysign(i, f); 629 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 630 631 enum e { one, 632 two }; 633 i = __builtin_elementwise_copysign(one, two); 634 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 635 636 enum f { three }; 637 enum f x = __builtin_elementwise_copysign(one, three); 638 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 639 640 _BitInt(32) ext; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}} 641 ext = __builtin_elementwise_copysign(ext, ext); 642 // expected-error@-1 {{1st argument must be a floating point type (was '_BitInt(32)')}} 643 644 const float cf32; 645 f = __builtin_elementwise_copysign(cf32, f); 646 f = __builtin_elementwise_copysign(f, cf32); 647 f = __builtin_elementwise_copysign(cf32, f); 648 649 f = __builtin_elementwise_copysign(f, float_as_one); // ok (attributes don't match)? 650 f = __builtin_elementwise_copysign(f, waf); // ok (sugar doesn't match)? 651 652 float A[10]; 653 A = __builtin_elementwise_copysign(A, A); 654 // expected-error@-1 {{1st argument must be a floating point type (was 'float *')}} 655 656 float(ii); 657 float j; 658 j = __builtin_elementwise_copysign(f, j); 659 660 _Complex float c1, c2; 661 c1 = __builtin_elementwise_copysign(c1, c2); 662 // expected-error@-1 {{1st argument must be a floating point type (was '_Complex float')}} 663 664 double f64 = 0.0; 665 double tmp0 = __builtin_elementwise_copysign(f64, f); 666 // expected-error@-1 {{arguments are of different types ('double' vs 'float')}} 667 668 float tmp1 = __builtin_elementwise_copysign(f, f64); 669 //expected-error@-1 {{arguments are of different types ('float' vs 'double')}} 670 671 float4 v4f32 = 0.0f; 672 float4 tmp2 = __builtin_elementwise_copysign(v4f32, f); 673 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'float')}} 674 675 float tmp3 = __builtin_elementwise_copysign(f, v4f32); 676 // expected-error@-1 {{arguments are of different types ('float' vs 'float4' (vector of 4 'float' values))}} 677 678 float2 v2f32 = 0.0f; 679 double4 v4f64 = 0.0; 680 double4 tmp4 = __builtin_elementwise_copysign(v4f64, v4f32); 681 // expected-error@-1 {{arguments are of different types ('double4' (vector of 4 'double' values) vs 'float4' (vector of 4 'float' values))}} 682 683 float4 tmp6 = __builtin_elementwise_copysign(v4f32, v4f64); 684 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'double4' (vector of 4 'double' values))}} 685 686 float4 tmp7 = __builtin_elementwise_copysign(v4f32, v2f32); 687 // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'float2' (vector of 2 'float' values))}} 688 689 float2 tmp8 = __builtin_elementwise_copysign(v2f32, v4f32); 690 // expected-error@-1 {{arguments are of different types ('float2' (vector of 2 'float' values) vs 'float4' (vector of 4 'float' values))}} 691 692 float2 tmp9 = __builtin_elementwise_copysign(v4f32, v4f32); 693 // expected-error@-1 {{initializing 'float2' (vector of 2 'float' values) with an expression of incompatible type 'float4' (vector of 4 'float' values)}} 694 } 695 696 void test_builtin_elementwise_fma(int i32, int2 v2i32, short i16, 697 double f64, double2 v2f64, double2 v3f64, 698 float f32, float2 v2f32, float v3f32, float4 v4f32, 699 const float4 c_v4f32, 700 int3 v3i32, int *ptr) { 701 702 f32 = __builtin_elementwise_fma(); 703 // expected-error@-1 {{too few arguments to function call, expected 3, have 0}} 704 705 f32 = __builtin_elementwise_fma(f32); 706 // expected-error@-1 {{too few arguments to function call, expected 3, have 1}} 707 708 f32 = __builtin_elementwise_fma(f32, f32); 709 // expected-error@-1 {{too few arguments to function call, expected 3, have 2}} 710 711 f32 = __builtin_elementwise_fma(f32, f32, f32, f32); 712 // expected-error@-1 {{too many arguments to function call, expected 3, have 4}} 713 714 f32 = __builtin_elementwise_fma(f64, f32, f32); 715 // expected-error@-1 {{arguments are of different types ('double' vs 'float')}} 716 717 f32 = __builtin_elementwise_fma(f32, f64, f32); 718 // expected-error@-1 {{arguments are of different types ('float' vs 'double')}} 719 720 f32 = __builtin_elementwise_fma(f32, f32, f64); 721 // expected-error@-1 {{arguments are of different types ('float' vs 'double')}} 722 723 f32 = __builtin_elementwise_fma(f32, f32, f64); 724 // expected-error@-1 {{arguments are of different types ('float' vs 'double')}} 725 726 f64 = __builtin_elementwise_fma(f64, f32, f32); 727 // expected-error@-1 {{arguments are of different types ('double' vs 'float')}} 728 729 f64 = __builtin_elementwise_fma(f64, f64, f32); 730 // expected-error@-1 {{arguments are of different types ('double' vs 'float')}} 731 732 f64 = __builtin_elementwise_fma(f64, f32, f64); 733 // expected-error@-1 {{arguments are of different types ('double' vs 'float')}} 734 735 v2f64 = __builtin_elementwise_fma(v2f32, f64, f64); 736 // expected-error@-1 {{arguments are of different types ('float2' (vector of 2 'float' values) vs 'double'}} 737 738 v2f64 = __builtin_elementwise_fma(v2f32, v2f64, f64); 739 // expected-error@-1 {{arguments are of different types ('float2' (vector of 2 'float' values) vs 'double2' (vector of 2 'double' values)}} 740 741 v2f64 = __builtin_elementwise_fma(v2f32, f64, v2f64); 742 // expected-error@-1 {{arguments are of different types ('float2' (vector of 2 'float' values) vs 'double'}} 743 744 v2f64 = __builtin_elementwise_fma(f64, v2f32, v2f64); 745 // expected-error@-1 {{arguments are of different types ('double' vs 'float2' (vector of 2 'float' values)}} 746 747 v2f64 = __builtin_elementwise_fma(f64, v2f64, v2f64); 748 // expected-error@-1 {{arguments are of different types ('double' vs 'double2' (vector of 2 'double' values)}} 749 750 i32 = __builtin_elementwise_fma(i32, i32, i32); 751 // expected-error@-1 {{1st argument must be a floating point type (was 'int')}} 752 753 v2i32 = __builtin_elementwise_fma(v2i32, v2i32, v2i32); 754 // expected-error@-1 {{1st argument must be a floating point type (was 'int2' (vector of 2 'int' values))}} 755 756 f32 = __builtin_elementwise_fma(f32, f32, i32); 757 // expected-error@-1 {{3rd argument must be a floating point type (was 'int')}} 758 759 f32 = __builtin_elementwise_fma(f32, i32, f32); 760 // expected-error@-1 {{2nd argument must be a floating point type (was 'int')}} 761 762 f32 = __builtin_elementwise_fma(f32, f32, i32); 763 // expected-error@-1 {{3rd argument must be a floating point type (was 'int')}} 764 765 766 _Complex float c1, c2, c3; 767 c1 = __builtin_elementwise_fma(c1, f32, f32); 768 // expected-error@-1 {{1st argument must be a floating point type (was '_Complex float')}} 769 770 c2 = __builtin_elementwise_fma(f32, c2, f32); 771 // expected-error@-1 {{2nd argument must be a floating point type (was '_Complex float')}} 772 773 c3 = __builtin_elementwise_fma(f32, f32, c3); 774 // expected-error@-1 {{3rd argument must be a floating point type (was '_Complex float')}} 775 } 776