2012-03-15 13:09:31 +08:00
// RUN: %clang_cc1 %s -verify -fsyntax-only -Wvector-conversion
2007-11-30 12:21:22 +08:00
typedef unsigned int v2u __attribute__ ( ( vector_size ( 8 ) ) ) ;
typedef signed int v2s __attribute__ ( ( vector_size ( 8 ) ) ) ;
typedef signed int v1s __attribute__ ( ( vector_size ( 4 ) ) ) ;
typedef float v2f __attribute__ ( ( vector_size ( 8 ) ) ) ;
typedef signed short v4ss __attribute__ ( ( vector_size ( 8 ) ) ) ;
2009-10-18 04:33:28 +08:00
void test1 ( ) {
2007-11-30 12:21:22 +08:00
v2s v1 ;
v2u v2 ;
v1s v3 ;
v2f v4 ;
v4ss v5 ;
2014-04-26 04:41:38 +08:00
v1 = v2 ; // expected-warning {{incompatible vector types assigning to 'v2s' (vector of 2 'int' values) from 'v2u' (vector of 2 'unsigned int' values)}}
v1 = v3 ; // expected-error {{assigning to 'v2s' (vector of 2 'int' values) from incompatible type 'v1s' (vector of 1 'int' value)}}
2020-01-21 08:34:09 +08:00
v1 = v4 ; // expected-warning {{incompatible vector types assigning to 'v2s' (vector of 2 'int' values) from 'v2f' (vector of 2 'float' values)}}
2014-04-26 04:41:38 +08:00
v1 = v5 ; // expected-warning {{incompatible vector types assigning to 'v2s' (vector of 2 'int' values) from 'v4ss' (vector of 4 'short' values)}}
2007-11-30 12:21:22 +08:00
2014-04-26 04:41:38 +08:00
v2 = v1 ; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'v2s' (vector of 2 'int' values)}}
v2 = v3 ; // expected-error {{assigning to 'v2u' (vector of 2 'unsigned int' values) from incompatible type 'v1s' (vector of 1 'int' value)}}
2020-01-21 08:34:09 +08:00
v2 = v4 ; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'v2f' (vector of 2 'float' values)}}
2014-04-26 04:41:38 +08:00
v2 = v5 ; // expected-warning {{incompatible vector types assigning to 'v2u' (vector of 2 'unsigned int' values) from 'v4ss' (vector of 4 'short' values)}}
2007-11-30 12:21:22 +08:00
2014-04-26 04:41:38 +08:00
v3 = v1 ; // expected-error {{assigning to 'v1s' (vector of 1 'int' value) from incompatible type 'v2s' (vector of 2 'int' values)}}
v3 = v2 ; // expected-error {{assigning to 'v1s' (vector of 1 'int' value) from incompatible type 'v2u' (vector of 2 'unsigned int' values)}}
v3 = v4 ; // expected-error {{assigning to 'v1s' (vector of 1 'int' value) from incompatible type 'v2f' (vector of 2 'float' values)}}
v3 = v5 ; // expected-error {{assigning to 'v1s' (vector of 1 'int' value) from incompatible type 'v4ss'}}
2007-11-30 12:21:22 +08:00
2020-01-21 08:34:09 +08:00
v4 = v1 ; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from 'v2s' (vector of 2 'int' values)}}
v4 = v2 ; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from 'v2u' (vector of 2 'unsigned int' values)}}
2014-04-26 04:41:38 +08:00
v4 = v3 ; // expected-error {{assigning to 'v2f' (vector of 2 'float' values) from incompatible type 'v1s' (vector of 1 'int' value)}}
2020-01-21 08:34:09 +08:00
v4 = v5 ; // expected-warning {{incompatible vector types assigning to 'v2f' (vector of 2 'float' values) from 'v4ss' (vector of 4 'short' values)}}
2007-11-30 12:21:22 +08:00
2014-04-26 04:41:38 +08:00
v5 = v1 ; // expected-warning {{incompatible vector types assigning to 'v4ss' (vector of 4 'short' values) from 'v2s' (vector of 2 'int' values)}}
v5 = v2 ; // expected-warning {{incompatible vector types assigning to 'v4ss' (vector of 4 'short' values) from 'v2u' (vector of 2 'unsigned int' values)}}
v5 = v3 ; // expected-error {{assigning to 'v4ss' (vector of 4 'short' values) from incompatible type 'v1s' (vector of 1 'int' value)}}
2020-01-21 08:34:09 +08:00
v5 = v4 ; // expected-warning {{incompatible vector types assigning to 'v4ss' (vector of 4 'short' values) from 'v2f'}}
2007-11-30 12:21:22 +08:00
}
2008-05-13 02:31:17 +08:00
// PR2263
2009-10-18 04:33:28 +08:00
float test2 ( __attribute__ ( ( vector_size ( 16 ) ) ) float a , int b ) {
2008-05-13 02:31:17 +08:00
return a [ b ] ;
}
2009-10-18 04:33:28 +08:00
// PR4838
typedef long long __attribute__ ( ( __vector_size__ ( 2 * sizeof ( long long ) ) ) )
longlongvec ;
2010-04-22 08:20:18 +08:00
void test3a ( longlongvec * ) ; // expected-note{{passing argument to parameter here}}
2009-10-18 04:33:28 +08:00
void test3 ( const unsigned * src ) {
2010-09-05 08:04:01 +08:00
test3a ( src ) ; // expected-warning {{incompatible pointer types passing 'const unsigned int *' to parameter of type 'longlongvec *'}}
2009-10-18 04:33:28 +08:00
}