1
1
// RUN: %clang_cc1 -std=c99 %s -pedantic -verify -triple=x86_64-apple-darwin9
2
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 )));
3
6
typedef float float4 __attribute__((ext_vector_type (4 )));
4
7
typedef int int3 __attribute__((ext_vector_type (3 )));
5
8
typedef unsigned unsigned3 __attribute__((ext_vector_type (3 )));
@@ -13,6 +16,11 @@ __attribute__((address_space(1))) int int_as_one;
13
16
typedef int bar ;
14
17
bar b ;
15
18
19
+ __attribute__((address_space (1 ))) float float_as_one ;
20
+ typedef float waffle ;
21
+ waffle waf ;
22
+
23
+
16
24
void test_builtin_elementwise_abs (int i , double d , float4 v , int3 iv , unsigned u , unsigned4 uv ) {
17
25
struct Foo s = __builtin_elementwise_abs (i );
18
26
// expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
@@ -406,12 +414,12 @@ void test_builtin_elementwise_canonicalize(int i, float f, double d, float4 v, i
406
414
// expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
407
415
}
408
416
409
- void test_builtin_elementwise_copysign (int i , short s , double d , float4 v , int3 iv , unsigned3 uv , int * p ) {
417
+ void test_builtin_elementwise_copysign (int i , short s , double d , float f , float4 v , int3 iv , unsigned3 uv , int * p ) {
410
418
i = __builtin_elementwise_copysign (p , d );
411
- // expected-error@-1 {{arguments are of different types ( 'int *' vs 'double ')}}
419
+ // expected-error@-1 {{1st argument must be a floating point type (was 'int *')}}
412
420
413
- struct Foo foo = __builtin_elementwise_copysign (i , i );
414
- // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
421
+ i = __builtin_elementwise_copysign (i , i );
422
+ // expected-error@-1 {{1st argument must be a floating point type (was 'int') }}
415
423
416
424
i = __builtin_elementwise_copysign (i );
417
425
// expected-error@-1 {{too few arguments to function call, expected 2, have 1}}
@@ -423,40 +431,81 @@ void test_builtin_elementwise_copysign(int i, short s, double d, float4 v, int3
423
431
// expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
424
432
425
433
i = __builtin_elementwise_copysign (v , iv );
426
- // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'int3' (vector of 3 'int' values))}}
434
+ // expected-error@-1 {{2nd argument must be a floating point type (was 'int3' (vector of 3 'int' values))}}
427
435
428
436
i = __builtin_elementwise_copysign (uv , iv );
429
- // expected-error@-1 {{arguments are of different types ('unsigned3' (vector of 3 'unsigned int' values) vs 'int3' (vector of 3 'int' values))}}
437
+ // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned3' (vector of 3 'unsigned int' values))}}
430
438
431
439
s = __builtin_elementwise_copysign (i , s );
440
+ // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
441
+
442
+ f = __builtin_elementwise_copysign (f , i );
443
+ // expected-error@-1 {{2nd argument must be a floating point type (was 'int')}}
444
+
445
+ f = __builtin_elementwise_copysign (i , f );
446
+ // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
432
447
433
448
enum e { one ,
434
449
two };
435
450
i = __builtin_elementwise_copysign (one , two );
451
+ // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
436
452
437
453
enum f { three };
438
454
enum f x = __builtin_elementwise_copysign (one , three );
455
+ // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
439
456
440
457
_BitInt (32 ) ext ; // expected-warning {{'_BitInt' in C17 and earlier is a Clang extension}}
441
458
ext = __builtin_elementwise_copysign (ext , ext );
459
+ // expected-error@-1 {{1st argument must be a floating point type (was '_BitInt(32)')}}
442
460
443
- const int ci ;
444
- i = __builtin_elementwise_copysign (ci , i );
445
- i = __builtin_elementwise_copysign (i , ci );
446
- i = __builtin_elementwise_copysign (ci , ci );
461
+ const float cf32 ;
462
+ f = __builtin_elementwise_copysign (cf32 , f );
463
+ f = __builtin_elementwise_copysign (f , cf32 );
464
+ f = __builtin_elementwise_copysign (cf32 , f );
447
465
448
- i = __builtin_elementwise_copysign (i , int_as_one ); // ok (attributes don't match)?
449
- i = __builtin_elementwise_copysign (i , b ); // ok (sugar doesn't match)?
466
+ f = __builtin_elementwise_copysign (f , float_as_one ); // ok (attributes don't match)?
467
+ f = __builtin_elementwise_copysign (f , waf ); // ok (sugar doesn't match)?
450
468
451
- int A [10 ];
469
+ float A [10 ];
452
470
A = __builtin_elementwise_copysign (A , A );
453
- // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was 'int *')}}
471
+ // expected-error@-1 {{1st argument must be a floating point type (was 'float *')}}
454
472
455
- int (ii );
456
- int j ;
457
- j = __builtin_elementwise_copysign (i , j );
473
+ float (ii );
474
+ float j ;
475
+ j = __builtin_elementwise_copysign (f , j );
458
476
459
477
_Complex float c1 , c2 ;
460
478
c1 = __builtin_elementwise_copysign (c1 , c2 );
461
- // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
479
+ // expected-error@-1 {{1st argument must be a floating point type (was '_Complex float')}}
480
+
481
+ double f64 = 0.0 ;
482
+ double tmp0 = __builtin_elementwise_copysign (f64 , f );
483
+ // expected-error@-1 {{arguments are of different types ('double' vs 'float')}}
484
+
485
+ float tmp1 = __builtin_elementwise_copysign (f , f64 );
486
+ //expected-error@-1 {{arguments are of different types ('float' vs 'double')}}
487
+
488
+ float4 v4f32 = 0.0f ;
489
+ float4 tmp2 = __builtin_elementwise_copysign (v4f32 , f );
490
+ // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'float')}}
491
+
492
+ float tmp3 = __builtin_elementwise_copysign (f , v4f32 );
493
+ // expected-error@-1 {{arguments are of different types ('float' vs 'float4' (vector of 4 'float' values))}}
494
+
495
+ float2 v2f32 = 0.0f ;
496
+ double4 v4f64 = 0.0 ;
497
+ double4 tmp4 = __builtin_elementwise_copysign (v4f64 , v4f32 );
498
+ // expected-error@-1 {{arguments are of different types ('double4' (vector of 4 'double' values) vs 'float4' (vector of 4 'float' values))}}
499
+
500
+ float4 tmp6 = __builtin_elementwise_copysign (v4f32 , v4f64 );
501
+ // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'double4' (vector of 4 'double' values))}}
502
+
503
+ float4 tmp7 = __builtin_elementwise_copysign (v4f32 , v2f32 );
504
+ // expected-error@-1 {{arguments are of different types ('float4' (vector of 4 'float' values) vs 'float2' (vector of 2 'float' values))}}
505
+
506
+ float2 tmp8 = __builtin_elementwise_copysign (v2f32 , v4f32 );
507
+ // expected-error@-1 {{arguments are of different types ('float2' (vector of 2 'float' values) vs 'float4' (vector of 4 'float' values))}}
508
+
509
+ float2 tmp9 = __builtin_elementwise_copysign (v4f32 , v4f32 );
510
+ // expected-error@-1 {{initializing 'float2' (vector of 2 'float' values) with an expression of incompatible type 'float4' (vector of 4 'float' values)}}
462
511
}
0 commit comments